From dc12a919d0a837983b7c04cdaceda71036ca5780 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sat, 9 Apr 2022 16:18:56 +0200 Subject: [PATCH] feat: dirty bopytex, need to test it --- bopytex/bopytex.py | 26 +++++++++++++++++++++----- test/test_bopytex.py | 3 +++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/bopytex/bopytex.py b/bopytex/bopytex.py index a9aaa46..ab96156 100755 --- a/bopytex/bopytex.py +++ b/bopytex/bopytex.py @@ -8,6 +8,10 @@ Producing then compiling templates import logging import csv 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") steam_handler = logging.StreamHandler() @@ -46,23 +50,35 @@ def build_subjects(students_csv, quantity_subjects): def list_tex_files_no_tpl(dir="."): tex_files = [] 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) return tex_files def bopytex( template: str, - working_dir: str, students_csv: str, quantity_subjects: int, corr: bool, - dirty: bool, only_corr: bool, - crazy: 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() # ----------------------------- diff --git a/test/test_bopytex.py b/test/test_bopytex.py index c8b69c5..a752b8e 100644 --- a/test/test_bopytex.py +++ b/test/test_bopytex.py @@ -27,3 +27,6 @@ def test_build_subject_list_from_infos(): {"name": "test1", "date": "today", "number": "1"}, {"name": "test2", "date": "tomorow", "number": "2"}, ] + +def test_bopytex(): + pass