From 8d5bb0837725f81cee4fcf0f3109eb860e87119d Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Wed, 7 Feb 2024 09:52:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E5=85=83=E6=8C=82?= =?UTF-8?q?=E9=92=A9=E5=8A=9F=E8=83=BD=E5=B9=B6=E5=8A=A0=E5=85=A5=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/单元挂钩.py | 27 +++++++++++++++++++++++++++ 工具v2/工具面板.py | 4 +++- 工具v2/文本文件/config.json | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 工具v2/单元挂钩.py diff --git a/工具v2/单元挂钩.py b/工具v2/单元挂钩.py new file mode 100644 index 00000000..4f371573 --- /dev/null +++ b/工具v2/单元挂钩.py @@ -0,0 +1,27 @@ +from database_tools import * + +pro_dict = load_dict("../题库0.3/problems.json") +configjson = load_dict("文本文件/config.json")["单元挂钩.py"] + +if str(configjson["阶段"]).strip() == "1": + idexp = configjson["题号表达式"] + if idexp.strip() == "": + idlist = unUnitted(pro_dict) + else: + idlist = generate_number_set(idexp) + latex_body,tagrec = AutoAssignTagNotoLaTeX(idlist,pro_dict) + latex_raw = ReadTextFile("模板文件/讲义模板.txt") + latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,("待检查单元",latex_body)) + SaveTextFile(tagrec,"临时文件/单元对应.txt") + SaveTextFile(latex_data,"临时文件/待检查单元.tex") + if XeLaTeXCompile("临时文件","待检查单元.tex") == True: + print("处理成功.") + os.system("code 临时文件/单元对应.txt 临时文件/待检查单元.pdf") + else: + print("处理失败.") +elif str(configjson["阶段"]).strip() == "2": + output = UnitRectoMetadataText(ReadTextFile("临时文件/单元对应.txt")) + SaveTextFile(output,"文本文件/metadata.txt") + os.system("code 文本文件/metadata.txt") + + diff --git a/工具v2/工具面板.py b/工具v2/工具面板.py index ec1e5bb7..a9cc3be3 100644 --- a/工具v2/工具面板.py +++ b/工具v2/工具面板.py @@ -7,7 +7,7 @@ root = Tk() root.geometry('500x600') -root.title('题库0.3工具面板v2') +root.title('题库0.3工具面板v2-20240207') def temp(): pass @@ -92,7 +92,9 @@ MaintainenceMenu.add_command(label = "合并使用记录并排序", command = la MaintainenceMenu.add_separator() MaintainenceMenu.add_command(label = "统考数据导入", command = lambda: SetButton("统考数据导入",["统考数据导入.py"])) MaintainenceMenu.add_command(label = "手动统计结果导入", command = lambda: SetButton("手动统计结果导入",["临时文件/手动统计结果.txt"])) +MaintainenceMenu.add_separator() MaintainenceMenu.add_command(label = "文件或剪贴板提取答案", command = lambda: SetButton("文件或剪贴板提取答案",["文件或剪贴板提取答案.py"])) +MaintainenceMenu.add_command(label = "单元挂钩", command = lambda: SetButton("单元挂钩",["单元挂钩.py"])) MaintainenceMenu.add_separator() MaintainenceMenu.add_command(label = "移除关联题号", command = lambda: SetButton("移除关联题号",["文本文件/metadata.txt"])) MaintainenceMenu.add_separator() diff --git a/工具v2/文本文件/config.json b/工具v2/文本文件/config.json index b0c46f0b..f6bb09d7 100644 --- a/工具v2/文本文件/config.json +++ b/工具v2/文本文件/config.json @@ -72,5 +72,11 @@ "来自剪贴板": true, "文件地址": "d:/temp/test5.tex", "前缀": "答案: \\textcolor{red}{" + }, + "单元挂钩.py": { + "阶段": 2, + "阶段说明": "阶段为1表示对题号列表的题目自动赋单元, 阶段为2表示将 临时文件/单元对应.txt 中的数据转化为metadata.txt", + "题号表达式": "", + "题号说明": "此处仅针对第1阶段: 题号表达式为空字符串表示处理未赋单元的题目, 否则表示处理表达式所表示的那些题目" } } \ No newline at end of file