feat: dirty bopytex, need to test it

This commit is contained in:
Bertrand Benjamin 2022-04-09 16:18:56 +02:00
parent 374c5f7467
commit dc12a919d0
2 changed files with 24 additions and 5 deletions

View File

@ -8,6 +8,10 @@ Producing then compiling templates
import logging import logging
import csv import csv
import os import os
from bopytex.actions import ACTIONS
from bopytex.planner import only_corr_planner, planner
from bopytex.scheduler import Scheduler
formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s") formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")
steam_handler = logging.StreamHandler() steam_handler = logging.StreamHandler()
@ -46,23 +50,35 @@ def build_subjects(students_csv, quantity_subjects):
def list_tex_files_no_tpl(dir="."): def list_tex_files_no_tpl(dir="."):
tex_files = [] tex_files = []
for file in os.listdir(dir): for file in os.listdir(dir):
if file.endswith(".tex") and not file.startswith(tpl_): if file.endswith(".tex") and not file.startswith("tpl_"):
tex_files.append(file) tex_files.append(file)
return tex_files return tex_files
def bopytex( def bopytex(
template: str, template: str,
working_dir: str,
students_csv: str, students_csv: str,
quantity_subjects: int, quantity_subjects: int,
corr: bool, corr: bool,
dirty: bool,
only_corr: bool, only_corr: bool,
crazy: bool,
no_join: bool, no_join: bool,
no_pdf: bool,
actions: dict = ACTIONS,
): ):
pass
if only_corr:
tex_files = list_tex_files_no_tpl()
tasks = only_corr_planner(sources=tex_files, no_pdf=no_pdf, no_join=no_join)
else:
subjects = build_subjects(
students_csv=students_csv, quantity_subjects=quantity_subjects
)
tasks = planner(template, subjects, corr, no_join, no_pdf)
scheduler = Scheduler(actions, [template])
scheduler.append(tasks)
scheduler.run()
# ----------------------------- # -----------------------------

View File

@ -27,3 +27,6 @@ def test_build_subject_list_from_infos():
{"name": "test1", "date": "today", "number": "1"}, {"name": "test1", "date": "today", "number": "1"},
{"name": "test2", "date": "tomorow", "number": "2"}, {"name": "test2", "date": "tomorow", "number": "2"},
] ]
def test_bopytex():
pass