refact: planners accept only options in parameters
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
from bopytex.tasks import Task, activate_corr_on, compile_pdf, generate, join_pdfs
|
||||
|
||||
|
||||
class PlannerMissingOption(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def naming_template2source(template: str, metadatas: dict):
|
||||
return metadatas["number"] + template[3:]
|
||||
|
||||
@@ -18,12 +22,25 @@ def naming_join(template):
|
||||
|
||||
|
||||
def default_planner(
|
||||
template: str,
|
||||
subjects: list[dict],
|
||||
corr: bool = False,
|
||||
no_join: bool = False,
|
||||
no_pdf: bool = False,
|
||||
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 = []
|
||||
@@ -61,10 +78,21 @@ def default_planner(
|
||||
|
||||
|
||||
def only_corr_planner(
|
||||
sources=[],
|
||||
no_pdf: bool = False,
|
||||
no_join: bool = False,
|
||||
options: dict,
|
||||
) -> list[Task]:
|
||||
opt = {
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
}
|
||||
opt.update(options)
|
||||
|
||||
try:
|
||||
sources = opt["sources"]
|
||||
no_join = opt["no_join"]
|
||||
no_pdf = opt["no_pdf"]
|
||||
except KeyError:
|
||||
raise PlannerMissingOption("An option is missing")
|
||||
|
||||
tasks = []
|
||||
corr_pdfs = []
|
||||
|
||||
|
Reference in New Issue
Block a user