Feat: code planners and tests
This commit is contained in:
27
bopytex/actions.py
Normal file
27
bopytex/actions.py
Normal file
@@ -0,0 +1,27 @@
|
||||
def generate():
|
||||
pass
|
||||
|
||||
|
||||
def compile():
|
||||
pass
|
||||
|
||||
|
||||
def activate_corr():
|
||||
pass
|
||||
|
||||
|
||||
def join_pdf():
|
||||
pass
|
||||
|
||||
|
||||
def clean():
|
||||
pass
|
||||
|
||||
|
||||
ACTIONS = {
|
||||
"GENERATE": generate,
|
||||
"COMPILE": compile,
|
||||
"ACTIVATE_CORR": activate_corr,
|
||||
"JOIN_PDF": join_pdf,
|
||||
"clean": clean,
|
||||
}
|
||||
63
bopytex/planner.py
Normal file
63
bopytex/planner.py
Normal file
@@ -0,0 +1,63 @@
|
||||
""" Produce tasks to do
|
||||
|
||||
It essentially place things at the right place and define the way that files are named.
|
||||
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Task:
|
||||
action: str
|
||||
args: dict
|
||||
deps: list
|
||||
output: str
|
||||
|
||||
|
||||
def generate(template: str, meta: dict):
|
||||
"""Create a task to generate a subject"""
|
||||
return Task(
|
||||
action="GENERATE",
|
||||
args=meta,
|
||||
deps=[template],
|
||||
output=meta["subject"] + template[3:],
|
||||
)
|
||||
|
||||
|
||||
def activate_corr_on(src: str):
|
||||
"""Create a task to activate correction for src"""
|
||||
return Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={},
|
||||
deps=[src],
|
||||
output="corr_" + src,
|
||||
)
|
||||
|
||||
|
||||
def compile_pdf(src: str):
|
||||
"""Create a task to compile src"""
|
||||
return Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=[src],
|
||||
output=src[:-3] + "pdf"
|
||||
)
|
||||
|
||||
def join_pdfs(pdfs: list):
|
||||
""" Create task to join pdf together """
|
||||
return Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=pdfs,
|
||||
output="joined.pdf"
|
||||
)
|
||||
|
||||
|
||||
def clean(files: list):
|
||||
""" Create task to clean files"""
|
||||
return Task(
|
||||
action="CLEAN",
|
||||
args={},
|
||||
deps=files,
|
||||
output=None
|
||||
)
|
||||
Reference in New Issue
Block a user