diff --git a/tools/syscap_check.py b/tools/syscap_check.py index 99c550d1b4968f333e3e0c0162865c0cc160f683..a4932aab04230e8143c260a6cdefb0b900473c05 100644 --- a/tools/syscap_check.py +++ b/tools/syscap_check.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,6 @@ import json import re import argparse from prettytable import PrettyTable, ALL -import sys - -debug = True if sys.gettrace() else False def get_args(): @@ -83,14 +80,10 @@ def read_value_from_json(filepath: str, return f = open(filepath, 'r') data = json.load(f) - if debug: - print(filepath) for key in key_hierarchy: try: data = data[key] except KeyError: - if debug: - print('warning: can\'t find the key:"{}" in file "{}"'.format(key, filepath)) return finally: f.close() @@ -114,7 +107,7 @@ def collect_syscap_from_codec(filepath: str, pattern: str = r'{"(.*)"') -> tuple array_syscap_set.update(re.findall(ptrn, content)) array_syscap_dict[filepath] = list() for v in array_syscap_set: - array_syscap_dict[filepath].append(v) + array_syscap_dict.get(filepath).append(v) return array_syscap_set, array_syscap_dict @@ -311,16 +304,6 @@ def main(): bundle_key_heirarchy=bundle_syscap_heirarchy, bundles=bundles) -def test(): - h_path = "./bundle.json" - key_heirarchy = ("component", "syscap") - result_dict = dict() - read_value_from_json(h_path, key_heirarchy, result_dict, bundle_syscap_post_handler) - print(result_dict) - print(len(result_dict)) - - if __name__ == "__main__": main() - # test()