Preload some generate() variables

This commit is contained in:
Sage Vaillancourt 2021-07-29 22:15:07 -04:00
parent d1af841b41
commit fc037bd105
1 changed files with 6 additions and 5 deletions

View File

@ -16,6 +16,11 @@ def get_datetime():
now = datetime.now() now = datetime.now()
return now.strftime("%Y-%m-%d %H:%M:%S") return now.strftime("%Y-%m-%d %H:%M:%S")
root_dir = os.path.dirname(os.getcwd())
proj_dir = root_dir + '/undercover/'
output_dir = proj_dir + 'outputs/'
base_tex_text = open(proj_dir + "/writing_templates/base.tex", "r").read()
@dataclass @dataclass
class CLData(): class CLData():
username: str username: str
@ -40,15 +45,11 @@ class CLData():
def generate_pdf(self): def generate_pdf(self):
import threading import threading
unique_id = get_unique() unique_id = get_unique()
root_dir = os.path.dirname(os.getcwd())
proj_dir = root_dir + '/undercover/'
output_dir = proj_dir + 'outputs/'
unique_file = output_dir + unique_id + ".tex" unique_file = output_dir + unique_id + ".tex"
f = open(unique_file, "w") f = open(unique_file, "w")
for pair in self.get_pairs(): for pair in self.get_pairs():
f.write("\\def \\" + pair[0] + "{" + pair[1] + "}\n") f.write("\\def \\" + pair[0] + "{" + pair[1] + "}\n")
f.write(open(proj_dir + "/writing_templates/base.tex", "r").read()) f.write(base_tex_text)
f.close() f.close()
output_arg="-jobname=outputs/" + unique_id + " " + unique_file output_arg="-jobname=outputs/" + unique_id + " " + unique_file