Spaces:
Running
Running
修复extract_folder_path被定位到根目录的bug
Browse files
crazy_functions/解析项目源代码.py
CHANGED
@@ -292,13 +292,14 @@ def 解析任意code项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys
|
|
292 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
293 |
return
|
294 |
# 若上传压缩文件, 先寻找到解压的文件夹路径, 从而避免解析压缩文件
|
295 |
-
maybe_dir = [f for f in glob.glob(f'{project_folder}
|
296 |
-
|
|
|
|
|
|
|
297 |
# 按输入的匹配模式寻找上传的非压缩文件和已解压的文件
|
298 |
-
file_manifest = [f for f in glob.glob(f'{
|
299 |
-
|
300 |
-
os.path.isfile(f) and (not re.search(pattern_except, f) or _.endswith('.' + re.search(pattern_except, f).group().split('.')[-1]))]
|
301 |
-
|
302 |
if len(file_manifest) == 0:
|
303 |
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何文件: {txt}")
|
304 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
|
|
292 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
293 |
return
|
294 |
# 若上传压缩文件, 先寻找到解压的文件夹路径, 从而避免解析压缩文件
|
295 |
+
maybe_dir = [f for f in glob.glob(f'{project_folder}/*') if os.path.isdir(f)]
|
296 |
+
if maybe_dir[0].endswith('.extract'):
|
297 |
+
extract_folder_path = maybe_dir[0]
|
298 |
+
else:
|
299 |
+
extract_folder_path = project_folder
|
300 |
# 按输入的匹配模式寻找上传的非压缩文件和已解压的文件
|
301 |
+
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 \
|
302 |
+
os.path.isfile(f) and (not re.search(pattern_except, f) or pattern.endswith('.' + re.search(pattern_except, f).group().split('.')[-1]))]
|
|
|
|
|
303 |
if len(file_manifest) == 0:
|
304 |
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何文件: {txt}")
|
305 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|