1 Star 0 Fork 989

yaoxiaoyu_903c / build

forked from OpenHarmony / build 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
parse_vendor_product_config.py 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
yaoxiaoyu_903c 提交于 2022-01-10 11:16 . add script
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import sys
import json
import re
import os
subsystem_template = """
{{
"subsystem": "{}",
"components": [{}]
}}
"""
part_template = """
{{"component": "{}", "features":[]}}
"""
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--input-json', required=True)
parser.add_argument('--output-json', required=True)
options = parser.parse_args()
with open(options.input_json, 'rb') as fin:
config = json.load(fin)
parts = config.get('parts')
subsystems = []
info = {}
for key, _ in parts.items():
subsystem, part = key.split(':')
if info.get(subsystem):
tmp = info.get(subsystem)
tmp.append(part)
info[subsystem] = tmp
else:
info[subsystem] = [part]
for key, value in info.items():
parts = []
for part in value:
print(part)
#print(part_template.format(part))
parts.append(part_template.format(part))
subsystems.append(subsystem_template.format(key, ','.join(parts)))
with open(options.output_json, 'w') as out:
out.write(','.join(subsystems))
if __name__ == '__main__':
sys.exit(main())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yaoxiaoyu_903c/build.git
git@gitee.com:yaoxiaoyu_903c/build.git
yaoxiaoyu_903c
build
build
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891