From c6610b2aab958b3899d44b7e9b0b3d329c825f10 Mon Sep 17 00:00:00 2001 From: mrhblfx <116722876+mrhblfx@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=A3=E6=9E=90=E4=B8=80?= =?UTF-8?q?=E4=B8=AALua=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/解析项目源代码.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crazy_functions/解析项目源代码.py b/crazy_functions/解析项目源代码.py index 0edcbf1..c06e570 100644 --- a/crazy_functions/解析项目源代码.py +++ b/crazy_functions/解析项目源代码.py @@ -231,3 +231,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)