diff --git a/crazy_functional.py b/crazy_functional.py index 5a76757..8cfe558 100644 --- a/crazy_functional.py +++ b/crazy_functional.py @@ -155,6 +155,15 @@ def get_crazy_functions(): except Exception as err: print(f'[下载arxiv论文并翻译摘要] 插件导入失败 {str(err)}') + + from crazy_functions.解析项目源代码 import 解析一个Lua项目 + function_plugins.update({ + "解析整个Lua项目": { + "Color": "stop", # 按钮颜色 + "AsButton": False, # 加入下拉菜单中 + "Function": HotReload(解析一个Lua项目) + }, + }) ###################### 第n组插件 ########################### return function_plugins diff --git a/crazy_functions/解析项目源代码.py b/crazy_functions/解析项目源代码.py index 7c56e82..2cb96eb 100644 --- a/crazy_functions/解析项目源代码.py +++ b/crazy_functions/解析项目源代码.py @@ -234,3 +234,25 @@ def 解析一个Golang项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 return yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt) + + +@CatchException +def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): + history = [] # 清空历史,以免输入溢出 + import glob, os + if os.path.exists(txt): + project_folder = txt + else: + if txt == "": txt = '空空如也的输入栏' + report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}") + yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 + return + file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.lua', recursive=True)] + \ + [f for f in glob.glob(f'{project_folder}/**/*.xml', recursive=True)] + \ + [f for f in glob.glob(f'{project_folder}/**/*.json', recursive=True)] + \ + [f for f in glob.glob(f'{project_folder}/**/*.toml', recursive=True)] + if len(file_manifest) == 0: + report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何lua文件: {txt}") + yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 + return + yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)