Feat: activate solution worker
This commit is contained in:
parent
177128afe2
commit
37d779c0ab
@ -1,6 +1,6 @@
|
||||
#import jinja2 as j2
|
||||
from bopytex.planner.generate_compile_join_planner import planner
|
||||
from bopytex.worker import Dispatcher
|
||||
from bopytex.worker.activate_corr import activate_corr
|
||||
from bopytex.worker.clean import clean
|
||||
from bopytex.worker.compile import pdflatex
|
||||
from bopytex.worker.generate import generate
|
||||
@ -8,12 +8,19 @@ from bopytex.worker.join_pdf import pdfjam
|
||||
from bopytex.jinja2_env.texenv import texenv
|
||||
|
||||
jinja2 = {
|
||||
# "environment": j2.Environment(loader=j2.FileSystemLoader("./")),
|
||||
"environment": texenv
|
||||
}
|
||||
|
||||
dispatcher = Dispatcher(
|
||||
{"GENERATE": generate, "COMPILE": pdflatex, "JOIN": pdfjam, "CLEAN": clean}
|
||||
)
|
||||
dispatcher = Dispatcher({
|
||||
"GENERATE": generate,
|
||||
"COMPILE": pdflatex,
|
||||
"JOIN": pdfjam,
|
||||
"CLEAN": clean,
|
||||
"ACTIVATE_CORR": activate_corr,
|
||||
})
|
||||
|
||||
latex = {
|
||||
"solution": r"solution/print = true",
|
||||
"no_solution": r"solution/print = false",
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from bopytex.tasks import Task, activate_corr_on, compile_pdf, generate, join_pdfs
|
||||
from bopytex.tasks import Task, activate_corr_on, compile_pdf, join_pdfs
|
||||
import bopytex.planner.naming as naming
|
||||
import os
|
||||
|
||||
|
@ -80,7 +80,7 @@ def tasks_builder(
|
||||
|
||||
if corr:
|
||||
corr_source = naming.corr(source)
|
||||
tasks.append(activate_corr_on(source, corr_source))
|
||||
tasks.append(activate_corr_on(source, opt, corr_source))
|
||||
|
||||
if not no_pdf:
|
||||
corr_pdf = naming.source2pdf(corr_source)
|
||||
|
@ -24,11 +24,11 @@ def generate(template: str, meta: dict, output: str):
|
||||
)
|
||||
|
||||
|
||||
def activate_corr_on(src: str, output: str):
|
||||
def activate_corr_on(src: str, meta:dict, output: str):
|
||||
"""Create a task to activate correction for src"""
|
||||
return Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={},
|
||||
args=meta,
|
||||
deps=[src],
|
||||
output=output,
|
||||
)
|
||||
|
14
bopytex/worker/activate_corr.py
Normal file
14
bopytex/worker/activate_corr.py
Normal file
@ -0,0 +1,14 @@
|
||||
from bopytex.message import Message
|
||||
|
||||
|
||||
def activate_corr(args, deps, output):
|
||||
no_solution = args["latex"]["no_solution"]
|
||||
solution = args["latex"]["solution"]
|
||||
|
||||
with open(deps[0], "r") as input_f:
|
||||
with open(output, "w") as output_f:
|
||||
for line in input_f.readlines():
|
||||
output_f.write(line.replace(no_solution, solution))
|
||||
|
||||
return Message(0, [f"ACTIVATE CORR - {deps[0]} to {output}"], [])
|
||||
|
Binary file not shown.
@ -4,6 +4,8 @@
|
||||
|
||||
\title{Bopytex with Mapytex example -- \Var{ number }}
|
||||
|
||||
% solution/print = false
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
Loading…
Reference in New Issue
Block a user