This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具v2/单元挂钩old.py

28 lines
1.1 KiB
Python

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")