From ce243babb3de1ad7324908560fa72c9806e365e9 Mon Sep 17 00:00:00 2001 From: zhangwuf Date: Tue, 16 Jan 2024 15:50:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=84=E5=8C=BA=E6=89=AB=E6=8F=8F=E5=87=BA?= =?UTF-8?q?=E7=9A=84codecheck=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangwuf --- .../capi_parser/src/coreImpl/check/check.py | 24 +++++++++---------- .../src/coreImpl/diff/diff_file.py | 6 ++--- .../src/coreImpl/parser/generating_tables.py | 2 +- .../capi_parser/src/coreImpl/parser/parser.py | 3 ++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/build-tools/capi_parser/src/coreImpl/check/check.py b/build-tools/capi_parser/src/coreImpl/check/check.py index 153abf9b8..3702cf18c 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check.py +++ b/build-tools/capi_parser/src/coreImpl/check/check.py @@ -62,9 +62,9 @@ def process_all_json(python_obj): def write_in_txt(check_result, output_path): result_json = result_to_json(check_result) - fs = open(output_path, 'w', encoding='utf-8') - fs.write(result_json) - fs.close() + with open(output_path, 'w', encoding='utf-8') as fs: + fs.write(result_json) + fs.close() def result_to_json(check_result): @@ -96,16 +96,16 @@ def get_check_result_list(file_list): def get_md_files(md_files_path): - file = open(md_files_path, "r") - file_list = [] - line = file.readline() - while line: - file_path = line.splitlines()[0] - if file_path.find("sdk_c") != -1 and get_file_type(file_path) == '.h': - file_list.append(line.splitlines()[0]) + with open(md_files_path, 'r') as file: + file_list = [] line = file.readline() - file.close() - return file_list + while line: + file_path = line.splitlines()[0] + if file_path.find("sdk_c") != -1 and get_file_type(file_path) == '.h': + file_list.append(line.splitlines()[0]) + line = file.readline() + file.close() + return file_list def get_file_type(file_path): diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index 81b6edd9d..2cd9b1f54 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -81,9 +81,9 @@ def result_to_json(result_info_list): def write_in_txt(check_result, output_path): - fs = open(output_path, 'w', encoding='utf-8') - fs.write(check_result) - fs.close() + with open(output_path, 'w', encoding='utf-8') as fs: + fs.write(check_result) + fs.close() def do_diff(old_dir, new_dir): diff --git a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py index 1a266e50c..9e14eade6 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py +++ b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py @@ -80,7 +80,7 @@ def get_parm(item, parm): if item["parm"][i]["kind"] != 'PARM_DECL': continue else: - str_parm = item["parm"][i]["type"] + ' ' + item["parm"][i]["name"] + str_parm = '{} {}'.format(item["parm"][i]["type"], item["parm"][i]["name"]) parm.append(str_parm) item["parm"] = parm diff --git a/build-tools/capi_parser/src/coreImpl/parser/parser.py b/build-tools/capi_parser/src/coreImpl/parser/parser.py index 33d49d083..cba23d7ba 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parser.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parser.py @@ -129,7 +129,8 @@ def change_abs(include_files, dire_path): # 获取.h绝对路径 head = os.path.splitdrive(dire_path) # 获取windows盘路径 include_file = os.path.normpath(j_item) if 'third_party/node/src' in j_item: - include_file = include_file.replace('\\\\', StringConstant.REPLACE_WAREHOUSE.value + '\\') + include_file = include_file.replace('\\\\', + '{}{}'.format(StringConstant.REPLACE_WAREHOUSE.value, '\\')) else: # 去掉绝对路径的双\\,替换为interface_sdk_c include_file = include_file.replace('\\\\interface\\sdk_c', -- Gitee