From 6c9cdedc5a4a5b3e87e9a526048069943b1d8104 Mon Sep 17 00:00:00 2001 From: yfwang6 Date: Wed, 21 Sep 2022 16:08:26 +0800 Subject: [PATCH] wangyongfei modify for suggestion Signed-off-by: yfwang6 Change-Id: I23c60db11908dc9d5615ef03826158bc51a3f5ce --- process_internal.py | 67 ++++++++++++++++++++++++++++----------------- remove_internal.py | 4 +-- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/process_internal.py b/process_internal.py index ae1cab930a..7410d5deee 100755 --- a/process_internal.py +++ b/process_internal.py @@ -25,35 +25,52 @@ def copy_files(options): remove_dict = json.load(f) if options.name in remove_dict: rm_name = remove_dict[options.name] - if 'base' in rm_name: - file_list = rm_name['base'] - else: - file_list = [] - for file in os.listdir(options.input): - src = os.path.join(options.input, file) - if os.path.isfile(src) and ( - not 'global_remove' in rm_name or ( - 'global_remove' in rm_name and ( - not file in rm_name['global_remove']))): - format_src = format_path(src) - if options.ispublic == 'true': - if not 'sdk_build_public_remove' in rm_name: - file_list.append(format_src) - else: - if not file in rm_name['sdk_build_public_remove']: - file_list.append(format_src) - else: - file_list.append(format_src) + file_list = process_name(options.input, + options.ispublic, rm_name) else: - file_list = [] - for file in os.listdir(options.input): - src = os.path.join(options.input, file) - if os.path.isfile(src): - format_src = format_path(src) - file_list.append(format_src) + file_list = process_noname(options.input) return file_list +def process_name(target_dir, is_public, config_data): + if 'base' in config_data: + file_list = config_data['base'] + else: + file_list = [] + for file in os.listdir(target_dir): + src = os.path.join(target_dir, file) + if os.path.isfile(src) and ( + not 'global_remove' in config_data or ( + 'global_remove' in config_data and ( + not file in config_data['global_remove']))): + file_list = process_name_file(is_public, config_data, file_list, + src, file) + return file_list + + +def process_name_file(is_public, config_data, file_list, file_path, file_name): + format_src = format_path(file_path) + if is_public == 'true': + if not 'sdk_build_public_remove' in config_data: + file_list.append(format_src) + else: + if not file_name in config_data['sdk_build_public_remove']: + file_list.append(format_src) + else: + file_list.append(format_src) + return file_list + + +def process_noname(target_dir): + file_list = [] + for file in os.listdir(target_dir): + src = os.path.join(target_dir, file) + if os.path.isfile(src): + format_src = format_path(src) + file_list.append(format_src) + return file_list + + def format_path(filepath): return re.sub(r'.*(?=api/)', '', filepath); diff --git a/remove_internal.py b/remove_internal.py index 1c3c3f226b..63062f7475 100755 --- a/remove_internal.py +++ b/remove_internal.py @@ -18,12 +18,10 @@ import sys import optparse import shutil -# d.ts directories to be deleted -remove_list = ["@internal", "common", "form", "liteWearable", "config", "syscapCheck"] - # traversal all fill in project folder def copy_files(input_path, output_path): + remove_list = ["@internal", "common", "form", "liteWearable", "config", "syscapCheck"] for file in os.listdir(input_path): src = os.path.join(input_path, file) dst = os.path.join(output_path, file) -- Gitee