From 69b2e1c82e0652cac4151808b122c8cbfb83671c Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 4 May 2022 11:39:28 +0200 Subject: [PATCH] Refact: move config and workflow to bopytex --- bopytex/bopytex.py | 16 ++++++++++++++++ bopytex/default_config.py | 13 +++++++++++++ test/test_e2e.py | 18 +++--------------- 3 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 bopytex/bopytex.py create mode 100644 bopytex/default_config.py diff --git a/bopytex/bopytex.py b/bopytex/bopytex.py new file mode 100644 index 0000000..bfa345e --- /dev/null +++ b/bopytex/bopytex.py @@ -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 diff --git a/bopytex/default_config.py b/bopytex/default_config.py new file mode 100644 index 0000000..864d804 --- /dev/null +++ b/bopytex/default_config.py @@ -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} +) diff --git a/test/test_e2e.py b/test/test_e2e.py index d7487b3..3368fa6 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -1,14 +1,7 @@ import os import jinja2 from pathlib import Path -from bopytex.message import Message -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 +from bopytex.bopytex import bopytex import pytest @@ -49,13 +42,8 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path): "environment": jinja2_env, }, } - dispatcher = Dispatcher( - {"GENERATE": generate, "COMPILE": latexmk, "JOIN": pdfjam, "CLEAN": clean} - ) - orcherstre = orcherstrator(options, planner=planner, dispatcher=dispatcher) - messages = [] - for message in orcherstre: - assert message.status == 0 + bopytex(**options) assert Path("joined_source.pdf").exists() +