feat: add function to parse Golang projects

This commit adds a new function to parse Golang projects to the collection of crazy functions.
This commit is contained in:
wangyu 2023-04-01 19:19:36 +08:00
parent 0218efaae7
commit 594f4b24f6
2 changed files with 22 additions and 0 deletions

View File

@ -148,3 +148,20 @@ def 解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptT
return
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
@CatchException
def 解析一个Golang项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, 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 chatbot, history, '正常'
return
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.go', recursive=True)]
if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何golang文件: {txt}")
yield chatbot, history, '正常'
return
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)

View File

@ -14,6 +14,7 @@ def get_crazy_functionals():
from crazy_functions.解析项目源代码 import 解析一个Python项目
from crazy_functions.解析项目源代码 import 解析一个C项目的头文件
from crazy_functions.解析项目源代码 import 解析一个C项目
from crazy_functions.解析项目源代码 import 解析一个Golang项目
from crazy_functions.高级功能函数模板 import 高阶功能模板函数
from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
@ -35,6 +36,10 @@ def get_crazy_functionals():
"AsButton": False, # 加入下拉菜单中
"Function": 解析一个C项目
},
"解析整个Go项目": {
"Color": "stop", # 按钮颜色
"Function": 解析一个Golang项目
},
"读Tex论文写摘要": {
"Color": "stop", # 按钮颜色
"Function": 读文章写摘要