anosem/gentopic.py

22 lines
475 B
Python
Raw Normal View History

2021-09-14 20:17:38 +02:00
import os
import json
with open("topics/shema.tex","r") as f:
shema=f.read()
for fn,fno in [[f"dics/{zw}",zw.replace(".json","")] for zw in os.listdir("dics")]:
with open(fn,"r") as f:
dic=json.loads(f.read())
2021-10-06 21:32:33 +02:00
print(dic["paper"]+", "+dic["by"]+"("+dic["when"]+")")
2021-09-14 20:17:38 +02:00
ac=shema.replace("##name##",fno)
for key,val in dic.items():
ac=ac.replace(f"##{key}##",str(val))
with open(f"topics/{fno}.tex","w") as f:
f.write(ac)