Feat: Organize script to work in CLI
This commit is contained in:
parent
9d7f779f07
commit
d9bd4ca5a1
@ -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
|
||||
|
@ -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__":
|
||||
|
@ -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))
|
||||
|
||||
|
12
example/tpl_example.tex
Normal file
12
example/tpl_example.tex
Normal file
@ -0,0 +1,12 @@
|
||||
% vim:ft=tex:
|
||||
%
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\title{Bopytex example -- {{ number }}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
|
||||
\end{document}
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user