Bopytex/bopytex/tasks.py

65 lines
1.2 KiB
Python
Raw Permalink Normal View History

2022-04-08 17:34:38 +00:00
""" Produce tasks to do
2022-04-08 19:29:35 +00:00
It essentially place things at the right place.
2022-04-08 17:34:38 +00:00
"""
from dataclasses import dataclass
@dataclass
class Task:
action: str
args: dict
deps: list
2022-04-09 04:32:56 +00:00
output: str
2022-04-08 17:34:38 +00:00
2022-04-09 04:32:56 +00:00
def generate(template: str, meta: dict, output: str):
2022-04-08 17:34:38 +00:00
"""Create a task to generate a subject"""
return Task(
action="GENERATE",
args=meta,
deps=[template],
2022-04-09 04:32:56 +00:00
output=output,
2022-04-08 17:34:38 +00:00
)
2022-07-28 07:39:51 +00:00
def activate_corr_on(src: str, meta: dict, output: str):
2022-04-08 17:34:38 +00:00
"""Create a task to activate correction for src"""
return Task(
action="ACTIVATE_CORR",
2022-07-19 16:09:17 +00:00
args=meta,
2022-04-08 17:34:38 +00:00
deps=[src],
2022-04-09 04:32:56 +00:00
output=output,
2022-04-08 17:34:38 +00:00
)
2022-04-09 04:32:56 +00:00
def compile_pdf(src: str, output: str):
2022-04-08 17:34:38 +00:00
"""Create a task to compile src"""
return Task(
action="COMPILE",
args={},
deps=[src],
2022-04-09 04:32:56 +00:00
output=output,
2022-04-08 17:34:38 +00:00
)
2022-04-09 04:32:56 +00:00
def join_pdfs(pdfs: list, output: str):
"""Create task to join pdf together"""
2022-04-08 17:34:38 +00:00
return Task(
action="JOIN",
args={},
deps=pdfs,
2022-04-09 04:32:56 +00:00
output=output,
2022-04-08 17:34:38 +00:00
)
def clean(files: list):
2022-04-09 04:32:56 +00:00
"""Create task to clean files"""
2022-04-08 17:34:38 +00:00
return Task(
action="CLEAN",
args={},
deps=files,
2022-04-09 04:32:56 +00:00
output=None,
2022-04-08 17:34:38 +00:00
)