feat: only_corr_planner
This commit is contained in:
parent
f9dd70a2f1
commit
7f40b7c38f
|
@ -62,6 +62,27 @@ def planner(
|
|||
|
||||
|
||||
def only_corr_planner(
|
||||
sources=[],
|
||||
no_pdf: bool = False,
|
||||
no_join: bool = False,
|
||||
):
|
||||
pass
|
||||
) -> list[Task]:
|
||||
tasks = []
|
||||
corr_pdfs = []
|
||||
|
||||
for source in sources:
|
||||
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 = "joined.pdf"
|
||||
|
||||
if corr_pdfs:
|
||||
corr_joined = naming_corr(joined)
|
||||
tasks.append(join_pdfs(corr_pdfs, corr_joined))
|
||||
|
||||
return tasks
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from bopytex.planner import planner
|
||||
from bopytex.planner import only_corr_planner, planner
|
||||
from bopytex.tasks import Task
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ def test_planner_generate():
|
|||
),
|
||||
]
|
||||
|
||||
|
||||
def test_planner_generate_compile():
|
||||
tasks = planner(
|
||||
template="tpl_source.tex",
|
||||
|
@ -56,6 +57,7 @@ def test_planner_generate_compile():
|
|||
),
|
||||
]
|
||||
|
||||
|
||||
def test_planner_generate_compile_join():
|
||||
tasks = planner(
|
||||
template="tpl_source.tex",
|
||||
|
@ -90,16 +92,17 @@ def test_planner_generate_compile_join():
|
|||
action="JOIN",
|
||||
args={},
|
||||
deps=["01_source.pdf", "02_source.pdf"],
|
||||
output="joined_source.pdf"
|
||||
)
|
||||
output="joined_source.pdf",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_planner_generate_compile_corr():
|
||||
tasks = planner(
|
||||
template="tpl_source.tex",
|
||||
subjects=[{"number": "01"}, {"number": "02"}],
|
||||
corr=1,
|
||||
no_join=1
|
||||
no_join=1,
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
|
@ -152,6 +155,7 @@ def test_planner_generate_compile_corr():
|
|||
),
|
||||
]
|
||||
|
||||
|
||||
def test_planner_generate_compile_corr_joined():
|
||||
tasks = planner(
|
||||
template="tpl_source.tex",
|
||||
|
@ -211,13 +215,49 @@ def test_planner_generate_compile_corr_joined():
|
|||
action="JOIN",
|
||||
args={},
|
||||
deps=["01_source.pdf", "02_source.pdf"],
|
||||
output="joined_source.pdf"
|
||||
output="joined_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
||||
output="corr_joined_source.pdf"
|
||||
)
|
||||
output="corr_joined_source.pdf",
|
||||
),
|
||||
]
|
||||
|
||||
def test_only_corr_planner():
|
||||
tasks = only_corr_planner(
|
||||
sources = ["01_source.tex", "02_source.tex"],
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={},
|
||||
deps=["01_source.tex"],
|
||||
output="corr_01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_01_source.tex"],
|
||||
output="corr_01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={},
|
||||
deps=["02_source.tex"],
|
||||
output="corr_02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_02_source.tex"],
|
||||
output="corr_02_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
||||
output="corr_joined.pdf",
|
||||
),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue