63 lines
1.5 KiB
Python
63 lines
1.5 KiB
Python
from bopytex.tasks import Task, activate_corr_on, compile_pdf, generate, join_pdfs
|
|
import bopytex.planner.naming as naming
|
|
|
|
|
|
def default_planner(options: dict) -> list[Task]:
|
|
pass
|
|
|
|
|
|
def default_tasks_builder(
|
|
options: dict,
|
|
) -> list[Task]:
|
|
|
|
opt = {
|
|
"corr": False,
|
|
"no_join": False,
|
|
"no_pdf": False,
|
|
}
|
|
opt.update(options)
|
|
|
|
try:
|
|
template = opt["template"]
|
|
subjects = opt["subjects"]
|
|
corr = opt["corr"]
|
|
no_join = opt["no_join"]
|
|
no_pdf = opt["no_pdf"]
|
|
except KeyError:
|
|
raise PlannerMissingOption("An option is missing")
|
|
|
|
tasks = []
|
|
|
|
pdfs = []
|
|
corr_pdfs = []
|
|
|
|
for subject in subjects:
|
|
source = naming.template2source(template, subject)
|
|
|
|
tasks.append(generate(template, subject, source))
|
|
|
|
if not no_pdf:
|
|
pdf = naming.source2pdf(source)
|
|
tasks.append(compile_pdf(source, pdf))
|
|
pdfs.append(pdf)
|
|
|
|
if corr:
|
|
corr_source = naming.corr(source)
|
|
tasks.append(activate_corr_on(source, corr_source))
|
|
|
|
if not no_pdf:
|
|
corr_pdf = naming.source2pdf(corr_source)
|
|
tasks.append(compile_pdf(corr_source, corr_pdf))
|
|
corr_pdfs.append(corr_pdf)
|
|
|
|
if not no_join:
|
|
joined = naming.join(template)
|
|
if pdfs:
|
|
tasks.append(join_pdfs(pdfs, joined))
|
|
|
|
if corr_pdfs:
|
|
corr_joined = naming.corr(joined)
|
|
tasks.append(join_pdfs(corr_pdfs, corr_joined))
|
|
|
|
return tasks
|