1b1994897Sopenharmony_ci#!/usr/bin/env python3
2b1994897Sopenharmony_ci# -*- coding: utf-8 -*-
3b1994897Sopenharmony_ci#
4b1994897Sopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
5b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
6b1994897Sopenharmony_ci# you may not use this file except in compliance with the License.
7b1994897Sopenharmony_ci# You may obtain a copy of the License at
8b1994897Sopenharmony_ci#
9b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
10b1994897Sopenharmony_ci#
11b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
12b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
13b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14b1994897Sopenharmony_ci# See the License for the specific language governing permissions and
15b1994897Sopenharmony_ci# limitations under the License.
16b1994897Sopenharmony_ci
17b1994897Sopenharmony_ciimport os
18b1994897Sopenharmony_ciimport yaml
19b1994897Sopenharmony_ci
20b1994897Sopenharmony_ciCURRENT_VERSION = "13.0.0.0"
21b1994897Sopenharmony_ci
22b1994897Sopenharmony_ciscript_dir = os.path.dirname(os.path.realpath(__file__))
23b1994897Sopenharmony_ci
24b1994897Sopenharmony_ciisa_file_path = os.path.join(script_dir, 'isa.yaml')
25b1994897Sopenharmony_ci
26b1994897Sopenharmony_ci
27b1994897Sopenharmony_cidef check_version(yaml_file, cur_version):
28b1994897Sopenharmony_ci    try:
29b1994897Sopenharmony_ci        with open(yaml_file, 'r') as file:
30b1994897Sopenharmony_ci            data = yaml.safe_load(file)
31b1994897Sopenharmony_ci
32b1994897Sopenharmony_ci            file_version = data.get('version')
33b1994897Sopenharmony_ci
34b1994897Sopenharmony_ci            if file_version == cur_version:
35b1994897Sopenharmony_ci                print("No change in version!")
36b1994897Sopenharmony_ci            else:
37b1994897Sopenharmony_ci                print(f"[IMPORTANT] Version change detected ({cur_version} -> {file_version}), please contact the relevant domain.")
38b1994897Sopenharmony_ci    except Exception as e:
39b1994897Sopenharmony_ci        print(f"Error reading file: {e}")
40b1994897Sopenharmony_ci
41b1994897Sopenharmony_cicheck_version(isa_file_path, CURRENT_VERSION)
42