• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# Copyright (c) 2021 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import sys
17import os
18import argparse
19sys.path.append(
20    os.path.dirname(os.path.dirname(os.path.dirname(
21        os.path.abspath(__file__)))))
22from scripts.util import file_utils  # noqa: E402
23
24
25def main():
26    parser = argparse.ArgumentParser()
27    parser.add_argument('--part-name', required=True)
28    parser.add_argument('--part-subsystem-info-file', required=False)
29    args = parser.parse_args()
30
31    part_subsystem_info_file = 'build_configs/parts_info/part_subsystem.json'
32    if args.part_subsystem_info_file:
33        part_subsystem_info_file = args.part_subsystem_info_file
34    if not os.path.exists(part_subsystem_info_file):
35        raise Exception(
36            "file '{}' does not exist.".format(part_subsystem_info_file))
37
38    data = file_utils.read_json_file(part_subsystem_info_file)
39    if data is None:
40        raise Exception(
41            "read file '{}' failed.".format(part_subsystem_info_file))
42
43    subsystem_name = data.get(args.part_name)
44    if subsystem_name is None or subsystem_name == '':
45        raise Exception("subsystem name error, part_name='{}'".format(
46            args.part_name))
47    print(subsystem_name)
48    return 0
49
50
51if __name__ == '__main__':
52    sys.exit(main())
53