Refact: move config and workflow to bopytex

This commit is contained in:
Bertrand Benjamin 2022-05-04 11:39:28 +02:00
parent 87ebb4c284
commit 69b2e1c82e
3 changed files with 32 additions and 15 deletions

16
bopytex/bopytex.py Normal file
View File

@ -0,0 +1,16 @@
import bopytex.default_config as DEFAULT
from bopytex.service import orcherstrator
def bopytex(**options):
config = options.copy()
config["jinja2"] = {}
config["jinja2"]["environment"] = DEFAULT.jinja2_env
orcherstre = orcherstrator(
options, planner=DEFAULT.planner, dispatcher=DEFAULT.dispatcher
)
for message in orcherstre:
print(message)
assert message.status == 0

13
bopytex/default_config.py Normal file
View File

@ -0,0 +1,13 @@
import jinja2
from bopytex.planner.generate_compile_join_planner import planner
from bopytex.worker import Dispatcher
from bopytex.worker.clean import clean
from bopytex.worker.compile import latexmk
from bopytex.worker.generate import generate
from bopytex.worker.join_pdf import pdfjam
jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader("./"))
dispatcher = Dispatcher(
{"GENERATE": generate, "COMPILE": latexmk, "JOIN": pdfjam, "CLEAN": clean}
)

View File

@ -1,14 +1,7 @@
import os import os
import jinja2 import jinja2
from pathlib import Path from pathlib import Path
from bopytex.message import Message from bopytex.bopytex import bopytex
from bopytex.planner.generate_compile_join_planner import planner
from bopytex.service import orcherstrator
from bopytex.worker import Dispatcher
from bopytex.worker.clean import clean
from bopytex.worker.compile import latexmk
from bopytex.worker.generate import generate
from bopytex.worker.join_pdf import pdfjam
import pytest import pytest
@ -49,13 +42,8 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path):
"environment": jinja2_env, "environment": jinja2_env,
}, },
} }
dispatcher = Dispatcher(
{"GENERATE": generate, "COMPILE": latexmk, "JOIN": pdfjam, "CLEAN": clean}
)
orcherstre = orcherstrator(options, planner=planner, dispatcher=dispatcher)
messages = [] bopytex(**options)
for message in orcherstre:
assert message.status == 0
assert Path("joined_source.pdf").exists() assert Path("joined_source.pdf").exists()