refact: rename planner to default_planner

This commit is contained in:
2022-04-09 22:06:42 +02:00
parent e52b6eb064
commit 8c9d7bf9a2
3 changed files with 18 additions and 24 deletions

View File

@@ -17,7 +17,7 @@ def naming_join(template):
return naming_source2pdf("joined" + template[3:])
def planner(
def default_planner(
template: str,
subjects: list[dict],
corr: bool = False,

View File

@@ -5,22 +5,13 @@
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.planner import only_corr_planner, default_planner
from bopytex.scheduler import Scheduler
formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")
steam_handler = logging.StreamHandler()
steam_handler.setLevel(logging.DEBUG)
steam_handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(steam_handler)
def build_subject_list_from_infos(infos: list[dict]) -> list[dict]:
subjects = []
@@ -47,10 +38,10 @@ def build_subjects(students_csv, quantity_subjects):
return build_subject_list_from_qty(quantity_subjects)
def list_tex_files_no_tpl(dir="."):
def list_files(dir=".", accept=lambda _: True, reject=lambda _: False):
tex_files = []
for file in os.listdir(dir):
if file.endswith(".tex") and not file.startswith("tpl_"):
if accept(file) and not reject(file):
tex_files.append(file)
return tex_files
@@ -67,19 +58,21 @@ def bopytex(
):
if only_corr:
tex_files = list_tex_files_no_tpl()
tex_files = list_files(
accept=lambda x: x.endswith(".tex"),
reject=lambda x: x.startswith("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)
tasks = default_planner(template, subjects, corr, no_join, no_pdf)
scheduler = Scheduler([template])
scheduler.append(tasks)
for _ in scheduler.backlog:
for task in scheduler.backlog:
pass