From 89a75e26c3872ecce59842a454fc23229e7c3f03 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 22 Apr 2023 15:36:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dextract=5Ffolder=5Fpath?= =?UTF-8?q?=E8=A2=AB=E5=AE=9A=E4=BD=8D=E5=88=B0=E6=A0=B9=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/解析项目源代码.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crazy_functions/解析项目源代码.py b/crazy_functions/解析项目源代码.py index 60de1cb..5563d3b 100644 --- a/crazy_functions/解析项目源代码.py +++ b/crazy_functions/解析项目源代码.py @@ -292,13 +292,14 @@ def 解析任意code项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 return # 若上传压缩文件, 先寻找到解压的文件夹路径, 从而避免解析压缩文件 - maybe_dir = [f for f in glob.glob(f'{project_folder}/**') if os.path.isdir(f)] - extract_folder_path = maybe_dir[0].replace('\\', '/') if len(maybe_dir) != 0 else "" + maybe_dir = [f for f in glob.glob(f'{project_folder}/*') if os.path.isdir(f)] + if maybe_dir[0].endswith('.extract'): + extract_folder_path = maybe_dir[0] + else: + extract_folder_path = project_folder # 按输入的匹配模式寻找上传的非压缩文件和已解压的文件 - file_manifest = [f for f in glob.glob(f'{project_folder}/**') if os.path.isfile(f) and not re.search(pattern_except, f)] + \ - [f for _ in pattern_include for f in glob.glob(f'{extract_folder_path}/**/{_}', recursive=True) if "" != extract_folder_path and \ - os.path.isfile(f) and (not re.search(pattern_except, f) or _.endswith('.' + re.search(pattern_except, f).group().split('.')[-1]))] - + file_manifest = [f for pattern in pattern_include for f in glob.glob(f'{extract_folder_path}/**/{pattern}', recursive=True) if "" != extract_folder_path and \ + os.path.isfile(f) and (not re.search(pattern_except, f) or pattern.endswith('.' + re.search(pattern_except, f).group().split('.')[-1]))] if len(file_manifest) == 0: report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何文件: {txt}") yield from update_ui(chatbot=chatbot, history=history) # 刷新界面