diff --git a/bopytex/bopytex.py b/bopytex/bopytex.py index bfa345e..3776568 100644 --- a/bopytex/bopytex.py +++ b/bopytex/bopytex.py @@ -9,8 +9,7 @@ def bopytex(**options): config["jinja2"]["environment"] = DEFAULT.jinja2_env orcherstre = orcherstrator( - options, planner=DEFAULT.planner, dispatcher=DEFAULT.dispatcher + config, planner=DEFAULT.planner, dispatcher=DEFAULT.dispatcher ) for message in orcherstre: - print(message) - assert message.status == 0 + yield message diff --git a/bopytex/script.py b/bopytex/script.py index ee50405..3d1bdaf 100644 --- a/bopytex/script.py +++ b/bopytex/script.py @@ -5,7 +5,7 @@ import click import logging -from bopytex.service import bopytex +from bopytex.bopytex import bopytex formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s") steam_handler = logging.StreamHandler() @@ -21,7 +21,6 @@ logger.addHandler(steam_handler) "template", type=click.Path(exists=True), nargs=1, - # help="File with the template. The name should have the following form tpl_... .", ) @click.option( "-w", @@ -36,13 +35,6 @@ logger.addHandler(steam_handler) default="", help="CSV containing list of students names", ) -@click.option( - "-d", - "--dirty", - is_flag=True, - default=False, - help="Do not clean after compilation", -) @click.option( "-n", "--no-compile", @@ -50,6 +42,13 @@ logger.addHandler(steam_handler) default=False, help="Do not compile source code", ) +@click.option( + "-d", + "--dirty", + is_flag=True, + default=False, + help="Do not clean after compilation", +) @click.option( "-q", "--quantity_subjects", @@ -78,15 +77,15 @@ logger.addHandler(steam_handler) default=False, help="Create and compile correction while making subjects", ) -@click.option( - "-C", - "--crazy", - is_flag=True, - default=False, - help="Crazy mode. Tries and tries again until template feeding success!", -) def new(**options): - bopytex(**options) + for message in bopytex(**options): + try: + assert message.status == 0 + except AssertionError: + logger.warning(message) + break + else: + logger.info(message.out) if __name__ == "__main__": diff --git a/bopytex/worker/compile.py b/bopytex/worker/compile.py index f5ea32f..1c1b68d 100644 --- a/bopytex/worker/compile.py +++ b/bopytex/worker/compile.py @@ -6,11 +6,10 @@ from ..message import SubprocessMessage def latexmk(args: dict, deps, output): compile_process = subprocess.Popen( - ["latexmk", deps[0]], + ["latexmk", "-f", deps[0]], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True ) - #return SubprocessMessage(compile_process) return Message(compile_process.wait(), list(compile_process.stdout), list(compile_process.stderr)) diff --git a/example/tpl_example.tex b/example/tpl_example.tex new file mode 100644 index 0000000..d5245f8 --- /dev/null +++ b/example/tpl_example.tex @@ -0,0 +1,12 @@ +% vim:ft=tex: +% +\documentclass[12pt]{article} + +\title{Bopytex example -- {{ number }}} + +\begin{document} + +\maketitle + + +\end{document} diff --git a/test/test_e2e.py b/test/test_e2e.py index 3368fa6..0a0a609 100644 --- a/test/test_e2e.py +++ b/test/test_e2e.py @@ -16,7 +16,7 @@ def template_path(tmp_path): \\begin{document} First document. -Subject {{ subject }} +Subject {{ number }} \\end{document} """ ) @@ -43,7 +43,8 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path): }, } - bopytex(**options) + for message in bopytex(**options): + pass assert Path("joined_source.pdf").exists()