修改讲义生成.py, 生成合集的.tex文件
This commit is contained in:
parent
f5ed5ab6b8
commit
73fa96f026
19
工具v2/讲义生成.py
19
工具v2/讲义生成.py
|
|
@ -1,8 +1,8 @@
|
||||||
notes_dict_path = "../备课组/26届/校本材料.json" # 讲义(题,基础知识,目标)号码所在json数据库路径
|
notes_dict_path = "../备课组/26届/校本材料.json" # 讲义(题,基础知识,目标)号码所在json数据库路径
|
||||||
lessonpattern = r"[G]202602\d{2}" # 正则表达式, 数据库中讲义的编号([A-Z][0-9]{4}[(01)|(02)][[0-9]{2}), 字母表示类型, 四位数字表示届别, 2位数字表示学期及其他, 2位数字表示序号
|
lessonpattern = r"[G]2026021[45]" # 正则表达式, 数据库中讲义的编号([A-Z][0-9]{4}[(01)|(02)][[0-9]{2}), 字母表示类型, 四位数字表示届别, 2位数字表示学期及其他, 2位数字表示序号
|
||||||
outputdir = "d:/temp/26届材料" # 输出文件夹, 不建议修改
|
outputdir = "d:/temp/26届材料" # 输出文件夹, 不建议修改
|
||||||
answered = True # 设置是否编译答案
|
answered = False # 设置是否编译答案
|
||||||
consecutivenumbering = False # 设置是否用连续编号, 试卷请设为True, 普通讲义请设为False
|
consecutivenumbering = True # 设置是否用连续编号, 试卷请设为True, 普通讲义请设为False
|
||||||
|
|
||||||
from database_tools import *
|
from database_tools import *
|
||||||
|
|
||||||
|
|
@ -15,11 +15,20 @@ dictionaries = {}
|
||||||
for t in (obj_dict,basicknowledge_dict,pro_dict):
|
for t in (obj_dict,basicknowledge_dict,pro_dict):
|
||||||
dictionaries.update(t)
|
dictionaries.update(t)
|
||||||
|
|
||||||
|
papernames = []
|
||||||
multitexdata = []
|
multitexdata = []
|
||||||
for lessonid in notes_dict["notes"]:
|
for lessonid in notes_dict["notes"]:
|
||||||
if re.findall(lessonpattern,lessonid) != []:
|
if re.findall(lessonpattern,lessonid) != []:
|
||||||
filename = notes_dict["notes"][lessonid]["id"]+notes_dict["notes"][lessonid]["filename"]+".tex"
|
filename = notes_dict["notes"][lessonid]["id"]+notes_dict["notes"][lessonid]["filename"]+".tex"
|
||||||
texdata = GenerateSingleLessonNote(id = lessonid,notesdict = notes_dict, metadict = dictionaries, templatepath = ".\模板文件\讲义模板.txt", outputfilepath = os.path.join(outputdir,filename),consecutivenumbering=consecutivenumbering,answered=answered)
|
texdata = GenerateSingleLessonNote(id = lessonid,notesdict = notes_dict, metadict = dictionaries, templatepath = ".\模板文件\讲义模板.txt", outputfilepath = os.path.join(outputdir,filename),consecutivenumbering=consecutivenumbering,answered=answered)
|
||||||
multitexdata.append(texdata)
|
papernames.append(notes_dict["notes"][lessonid]["id"]+" \\ "+notes_dict["notes"][lessonid]["name"])
|
||||||
|
multitexdata.append(re.findall(r"\\begin\{enumerate\}[\s\S]*\\end\{enumerate\}",texdata)[0])
|
||||||
|
|
||||||
|
merged = ""
|
||||||
|
for i in range(len(papernames)):
|
||||||
|
merged += "\n\n\\chapter{"+papernames[i]+"}\n\n\n"
|
||||||
|
merged += multitexdata[i]
|
||||||
|
|
||||||
|
mergedtext = StringSubstitute(r"<<待替换[\d]+>>",ReadTextFile("./模板文件/合集模板.txt"),[merged])
|
||||||
|
|
||||||
|
SaveTextFile(mergedtext,os.path.join(outputdir,f"合集{GetDate()}.tex"))
|
||||||
Reference in New Issue