Fix: run pre-commit hooks
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Bertrand Benjamin 2022-07-28 09:39:51 +02:00
parent d5981d25e5
commit cd2fdc162e
35 changed files with 368 additions and 363 deletions

View File

@ -9,4 +9,3 @@ docker-build-usecase:
docker-usecase: docker-build-usecase docker-usecase: docker-build-usecase
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat 1_example.tex" docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat 1_example.tex"

View File

@ -1,3 +1,4 @@
from bopytex.jinja2_env.texenv import texenv
from bopytex.planner.generate_compile_join_planner import planner from bopytex.planner.generate_compile_join_planner import planner
from bopytex.worker import Dispatcher from bopytex.worker import Dispatcher
from bopytex.worker.activate_corr import activate_corr from bopytex.worker.activate_corr import activate_corr
@ -5,22 +6,20 @@ from bopytex.worker.clean import clean
from bopytex.worker.compile import pdflatex from bopytex.worker.compile import pdflatex
from bopytex.worker.generate import generate from bopytex.worker.generate import generate
from bopytex.worker.join_pdf import pdfjam from bopytex.worker.join_pdf import pdfjam
from bopytex.jinja2_env.texenv import texenv
jinja2 = { jinja2 = {"environment": texenv}
"environment": texenv
}
dispatcher = Dispatcher({ dispatcher = Dispatcher(
{
"GENERATE": generate, "GENERATE": generate,
"COMPILE": pdflatex, "COMPILE": pdflatex,
"JOIN": pdfjam, "JOIN": pdfjam,
"CLEAN": clean, "CLEAN": clean,
"ACTIVATE_CORR": activate_corr, "ACTIVATE_CORR": activate_corr,
}) }
)
latex = { latex = {
"solution": r"solution/print = true", "solution": r"solution/print = true",
"no_solution": r"solution/print = false", "no_solution": r"solution/print = false",
} }

View File

@ -1,4 +1,4 @@
class Message(): class Message:
def __init__(self, status, out, err): def __init__(self, status, out, err):
self._status = status self._status = status
self._out = out self._out = out
@ -19,6 +19,7 @@ class Message():
def __repr__(self): def __repr__(self):
return f"Message(status={self.status}, out={self.out}, err={self.err})" return f"Message(status={self.status}, out={self.out}, err={self.err})"
class SubprocessMessage(Message): class SubprocessMessage(Message):
def __init__(self, process): def __init__(self, process):
self._process = process self._process = process

View File

@ -1,7 +1,8 @@
from bopytex.tasks import Task, activate_corr_on, compile_pdf, join_pdfs
import bopytex.planner.naming as naming
import os import os
import bopytex.planner.naming as naming
from bopytex.tasks import Task, activate_corr_on, compile_pdf, join_pdfs
def list_files(dir=".", accept=lambda _: True, reject=lambda _: False): def list_files(dir=".", accept=lambda _: True, reject=lambda _: False):
files = [] files = []

View File

@ -1,7 +1,8 @@
from bopytex.tasks import Task, activate_corr_on, compile_pdf, generate, join_pdfs import csv
import bopytex.planner.naming as naming import bopytex.planner.naming as naming
from bopytex.planner.exceptions import PlannerMissingOption from bopytex.planner.exceptions import PlannerMissingOption
import csv from bopytex.tasks import Task, activate_corr_on, compile_pdf, generate, join_pdfs
def build_subject_list_from_infos(infos: list[dict]) -> list[dict]: def build_subject_list_from_infos(infos: list[dict]) -> list[dict]:
@ -70,10 +71,7 @@ def tasks_builder(
for subject in subjects: for subject in subjects:
source = naming.template2source(template, subject) source = naming.template2source(template, subject)
args = { args = {"subject": subject, "options": options}
"subject": subject,
"options": options
}
tasks.append(generate(template, args, source)) tasks.append(generate(template, args, source))

View File

@ -12,4 +12,3 @@ def source2pdf(source):
def join(template): def join(template):
return source2pdf("joined" + template[3:]) return source2pdf("joined" + template[3:])

View File

@ -2,9 +2,10 @@
# encoding: utf-8 # encoding: utf-8
import click
import logging import logging
import click
from bopytex.service import main from bopytex.service import main
formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s") formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")

View File

@ -8,8 +8,9 @@ Producing then compiling templates
import importlib.util import importlib.util
import os import os
from pathlib import Path from pathlib import Path
from bopytex.scheduler import Scheduler
from bopytex import default_config from bopytex import default_config
from bopytex.scheduler import Scheduler
def orcherstrator( def orcherstrator(

View File

@ -15,4 +15,3 @@ class Dispatcher:
) )
return choosen_action(args=task.args, deps=task.deps, output=task.output) return choosen_action(args=task.args, deps=task.deps, output=task.output)

View File

@ -11,4 +11,3 @@ def activate_corr(args, deps, output):
output_f.write(line.replace(no_solution, solution)) output_f.write(line.replace(no_solution, solution))
return Message(0, [f"ACTIVATE CORR - {deps[0]} to {output}"], []) return Message(0, [f"ACTIVATE CORR - {deps[0]} to {output}"], [])

View File

@ -1,6 +1,7 @@
import subprocess import subprocess
from bopytex.message import Message from bopytex.message import Message
from ..message import SubprocessMessage from ..message import SubprocessMessage

View File

@ -20,8 +20,7 @@ def pdfjam(args: dict, deps, output):
def gs(args: dict, deps, output): def gs(args: dict, deps, output):
"""Not working. The command works in terminal but not here""" """Not working. The command works in terminal but not here"""
joining_process = subprocess.Popen( joining_process = subprocess.Popen(
["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"] ["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"] + deps,
+ deps,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, universal_newlines=True,

View File

@ -198,5 +198,3 @@ SSH_TARGET_DIR=/var/docker/opytex.org/www/opytex
rsync_upload: html rsync_upload: html
rsync -e "ssh" -P -rvzc --delete $(BUILDDIR)/html/ $(SSH_CONF):$(SSH_TARGET_DIR) --cvs-exclude rsync -e "ssh" -P -rvzc --delete $(BUILDDIR)/html/ $(SSH_CONF):$(SSH_TARGET_DIR) --cvs-exclude

View File

@ -188,4 +188,3 @@ Calculer les longueurs $OC$ et $AB$.
%%% mode: latex %%% mode: latex
%%% TeX-master: "master" %%% TeX-master: "master"
%%% End: %%% End:

View File

@ -13,9 +13,9 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys
import os import os
import shlex import shlex
import sys
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
@ -31,46 +31,46 @@ import shlex
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
'sphinx.ext.autodoc', "sphinx.ext.autodoc",
'sphinx.ext.mathjax', "sphinx.ext.mathjax",
'sphinx.ext.ifconfig', "sphinx.ext.ifconfig",
'sphinx.ext.viewcode', "sphinx.ext.viewcode",
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ["_templates"]
# The suffix(es) of source filenames. # The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string: # You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md'] # source_suffix = ['.rst', '.md']
source_suffix = '.rst' source_suffix = ".rst"
# The encoding of source files. # The encoding of source files.
# source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = "index"
# General information about the project. # General information about the project.
project = 'Opytex' project = "Opytex"
copyright = '2016, Benjamin Bertrand' copyright = "2016, Benjamin Bertrand"
author = 'Benjamin Bertrand' author = "Benjamin Bertrand"
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.1' version = "0.1"
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1' release = "0.1"
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
# #
# This is also used if you do content translation via gettext catalogs. # This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases. # Usually you set "language" from the command line for these cases.
language = 'fr' language = "fr"
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
@ -98,7 +98,7 @@ exclude_patterns = []
# show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
# modindex_common_prefix = [] # modindex_common_prefix = []
@ -116,6 +116,7 @@ todo_include_todos = False
# a list of builtin themes. # a list of builtin themes.
# html_theme = 'alabaster' # html_theme = 'alabaster'
import sphinx_rtd_theme import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme" html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
@ -146,7 +147,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
@ -209,20 +210,17 @@ html_static_path = ['_static']
# html_search_scorer = 'scorer.js' # html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Opytexdoc' htmlhelp_basename = "Opytexdoc"
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', #'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt', #'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#'preamble': '', #'preamble': '',
# Latex figure (float) alignment # Latex figure (float) alignment
#'figure_align': 'htbp', #'figure_align': 'htbp',
} }
@ -231,8 +229,7 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'Opytex.tex', 'Opytex Documentation', (master_doc, "Opytex.tex", "Opytex Documentation", "Benjamin Bertrand", "manual"),
'Benjamin Bertrand', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
@ -260,10 +257,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [(master_doc, "opytex", "Opytex Documentation", [author], 1)]
(master_doc, 'opytex', 'Opytex Documentation',
[author], 1)
]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
# man_show_urls = False # man_show_urls = False
@ -275,9 +269,15 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'Opytex', 'Opytex Documentation', (
author, 'Opytex', 'One line description of project.', master_doc,
'Miscellaneous'), "Opytex",
"Opytex Documentation",
author,
"Opytex",
"One line description of project.",
"Miscellaneous",
),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.

View File

@ -38,4 +38,3 @@ Indices and tables
* :ref:`genindex` * :ref:`genindex`
* :ref:`modindex` * :ref:`modindex`
* :ref:`search` * :ref:`search`

View File

@ -158,6 +158,3 @@ Il est possible aussi de créer les sujets et les corrections en même temps ave
.. code-block:: bash .. code-block:: bash
opytex -t tpl_DM.tex -c -N 60 opytex -t tpl_DM.tex -c -N 60

View File

@ -1,4 +1,3 @@
from mapytex import Expression from mapytex import Expression
direct_access = {
"Expression": Expression direct_access = {"Expression": Expression}
}

View File

@ -1,5 +1,6 @@
from bopytex.worker import Dispatcher from bopytex.worker import Dispatcher
from .workers import fake_worker, success_worker, fail_worker
from .workers import fail_worker, fake_worker, success_worker
fake_dispatcher = Dispatcher( fake_dispatcher = Dispatcher(
{ {

View File

@ -1,5 +1,6 @@
from bopytex.message import Message from bopytex.message import Message
def fake_worker(args, deps, output): def fake_worker(args, deps, output):
return Message(0, [f"FAKE - {args} - {deps} - {output}"], []) return Message(0, [f"FAKE - {args} - {deps} - {output}"], [])
@ -10,4 +11,3 @@ def success_worker(args, deps, output):
def fail_worker(args, deps, output): def fail_worker(args, deps, output):
return Message(1, [f"FAILURE - {args} - {deps} - {output}"], []) return Message(1, [f"FAILURE - {args} - {deps} - {output}"], [])

View File

@ -1,9 +1,11 @@
import os import os
import jinja2
from pathlib import Path from pathlib import Path
from bopytex.service import main
import jinja2
import pytest import pytest
from bopytex.service import main
@pytest.fixture @pytest.fixture
def template_path(tmp_path): def template_path(tmp_path):
@ -22,6 +24,7 @@ Subject {{ number }}
) )
return template return template
@pytest.fixture @pytest.fixture
def bad_template_path(tmp_path): def bad_template_path(tmp_path):
template = tmp_path / "tpl_source.tex" template = tmp_path / "tpl_source.tex"
@ -64,6 +67,7 @@ def test_with_default_planner(template_path, jinja2_env, tmp_path):
assert Path("joined_source.pdf").exists() assert Path("joined_source.pdf").exists()
def test_with_default_planner_bad_template(bad_template_path, jinja2_env, tmp_path): def test_with_default_planner_bad_template(bad_template_path, jinja2_env, tmp_path):
os.chdir(tmp_path) os.chdir(tmp_path)
@ -82,4 +86,3 @@ def test_with_default_planner_bad_template(bad_template_path, jinja2_env, tmp_pa
pass pass
assert not Path("joined_source.pdf").exists() assert not Path("joined_source.pdf").exists()

View File

@ -1,5 +1,9 @@
from bopytex.planner.generate_compile_join_planner import tasks_builder as gcj_task_builder from bopytex.planner.activate_corr_compile_join_planner import (
from bopytex.planner.activate_corr_compile_join_planner import tasks_builder as accj_task_builder tasks_builder as accj_task_builder,
)
from bopytex.planner.generate_compile_join_planner import (
tasks_builder as gcj_task_builder,
)
from bopytex.tasks import Task from bopytex.tasks import Task
@ -18,9 +22,9 @@ def test_tasks_builder_generate():
"options": { "options": {
"no_pdf": True, "no_pdf": True,
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "01"} "subject": {"number": "01"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="01_source.tex", output="01_source.tex",
@ -31,9 +35,9 @@ def test_tasks_builder_generate():
"options": { "options": {
"no_pdf": True, "no_pdf": True,
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "02"} "subject": {"number": "02"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="02_source.tex", output="02_source.tex",
@ -56,9 +60,9 @@ def test_tasks_builder_generate_compile():
"options": { "options": {
"no_join": True, "no_join": True,
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "01"} "subject": {"number": "01"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="01_source.tex", output="01_source.tex",
@ -75,9 +79,9 @@ def test_tasks_builder_generate_compile():
"options": { "options": {
"no_join": True, "no_join": True,
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "02"} "subject": {"number": "02"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="02_source.tex", output="02_source.tex",
@ -104,9 +108,9 @@ def test_tasks_builder_generate_compile_join():
args={ args={
"options": { "options": {
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "01"} "subject": {"number": "01"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="01_source.tex", output="01_source.tex",
@ -122,9 +126,9 @@ def test_tasks_builder_generate_compile_join():
args={ args={
"options": { "options": {
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "02"} "subject": {"number": "02"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="02_source.tex", output="02_source.tex",
@ -161,9 +165,9 @@ def test_tasks_builder_generate_compile_corr():
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
"corr": True, "corr": True,
"no_join": True, "no_join": True,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "01"} "subject": {"number": "01"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="01_source.tex", output="01_source.tex",
@ -177,11 +181,11 @@ def test_tasks_builder_generate_compile_corr():
Task( Task(
action="ACTIVATE_CORR", action="ACTIVATE_CORR",
args={ args={
'corr': True, "corr": True,
'no_join': True, "no_join": True,
'no_pdf': False, "no_pdf": False,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
"subjects": [{'number': '01'}, {'number': '02'}] "subjects": [{"number": "01"}, {"number": "02"}],
}, },
deps=["01_source.tex"], deps=["01_source.tex"],
output="corr_01_source.tex", output="corr_01_source.tex",
@ -199,9 +203,9 @@ def test_tasks_builder_generate_compile_corr():
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
"corr": True, "corr": True,
"no_join": True, "no_join": True,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "02"} "subject": {"number": "02"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="02_source.tex", output="02_source.tex",
@ -215,11 +219,11 @@ def test_tasks_builder_generate_compile_corr():
Task( Task(
action="ACTIVATE_CORR", action="ACTIVATE_CORR",
args={ args={
'corr': True, "corr": True,
'no_join': True, "no_join": True,
'no_pdf': False, "no_pdf": False,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
"subjects": [{'number': '01'}, {'number': '02'}] "subjects": [{"number": "01"}, {"number": "02"}],
}, },
deps=["02_source.tex"], deps=["02_source.tex"],
output="corr_02_source.tex", output="corr_02_source.tex",
@ -250,9 +254,9 @@ def test_tasks_builder_generate_compile_corr_joined():
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
"corr": True, "corr": True,
"no_join": False, "no_join": False,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "01"} "subject": {"number": "01"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="01_source.tex", output="01_source.tex",
@ -266,11 +270,11 @@ def test_tasks_builder_generate_compile_corr_joined():
Task( Task(
action="ACTIVATE_CORR", action="ACTIVATE_CORR",
args={ args={
'corr': True, "corr": True,
'no_join': False, "no_join": False,
'no_pdf': False, "no_pdf": False,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
"subjects": [{'number': '01'}, {'number': '02'}] "subjects": [{"number": "01"}, {"number": "02"}],
}, },
deps=["01_source.tex"], deps=["01_source.tex"],
output="corr_01_source.tex", output="corr_01_source.tex",
@ -288,9 +292,9 @@ def test_tasks_builder_generate_compile_corr_joined():
"subjects": [{"number": "01"}, {"number": "02"}], "subjects": [{"number": "01"}, {"number": "02"}],
"corr": True, "corr": True,
"no_join": False, "no_join": False,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
}, },
"subject": {"number": "02"} "subject": {"number": "02"},
}, },
deps=["tpl_source.tex"], deps=["tpl_source.tex"],
output="02_source.tex", output="02_source.tex",
@ -304,11 +308,11 @@ def test_tasks_builder_generate_compile_corr_joined():
Task( Task(
action="ACTIVATE_CORR", action="ACTIVATE_CORR",
args={ args={
'corr': True, "corr": True,
'no_join': False, "no_join": False,
'no_pdf': False, "no_pdf": False,
'template': 'tpl_source.tex', "template": "tpl_source.tex",
"subjects": [{'number': '01'}, {'number': '02'}] "subjects": [{"number": "01"}, {"number": "02"}],
}, },
deps=["02_source.tex"], deps=["02_source.tex"],
output="corr_02_source.tex", output="corr_02_source.tex",
@ -344,9 +348,9 @@ def test_only_corr_tasks_builder():
Task( Task(
action="ACTIVATE_CORR", action="ACTIVATE_CORR",
args={ args={
'no_join': False, "no_join": False,
'no_pdf': False, "no_pdf": False,
'sources': ['01_source.tex', '02_source.tex'] "sources": ["01_source.tex", "02_source.tex"],
}, },
deps=["01_source.tex"], deps=["01_source.tex"],
output="corr_01_source.tex", output="corr_01_source.tex",
@ -360,9 +364,9 @@ def test_only_corr_tasks_builder():
Task( Task(
action="ACTIVATE_CORR", action="ACTIVATE_CORR",
args={ args={
'no_join': False, "no_join": False,
'no_pdf': False, "no_pdf": False,
'sources': ['01_source.tex', '02_source.tex'] "sources": ["01_source.tex", "02_source.tex"],
}, },
deps=["02_source.tex"], deps=["02_source.tex"],
output="corr_02_source.tex", output="corr_02_source.tex",

View File

@ -1,9 +1,11 @@
from bopytex.message import Message
from bopytex.tasks import Task
from bopytex.scheduler import Scheduler
from .fakes.dispatcher import fake_dispatcher
import pytest import pytest
from bopytex.message import Message
from bopytex.scheduler import Scheduler
from bopytex.tasks import Task
from .fakes.dispatcher import fake_dispatcher
def test_schedule_append(): def test_schedule_append():
scheduler = Scheduler(dispatcher=fake_dispatcher) scheduler = Scheduler(dispatcher=fake_dispatcher)

View File

@ -1,10 +1,12 @@
import os import os
import pytest import pytest
from bopytex.planner import fake_planner from bopytex.planner import fake_planner
from bopytex.service import build_config, orcherstrator from bopytex.service import build_config, orcherstrator
from bopytex.tasks import Task from bopytex.tasks import Task
from bopytex.worker import Dispatcher from bopytex.worker import Dispatcher
from .fakes.workers import fake_worker from .fakes.workers import fake_worker

View File

@ -22,6 +22,7 @@ def test_block_line_statement():
output = jinja2_template.render() output = jinja2_template.render()
assert output == "2" assert output == "2"
def test_block_line_statement_with_comment(): def test_block_line_statement_with_comment():
base_template = r"""%-set a = 2 base_template = r"""%-set a = 2
%# comment %# comment
@ -30,11 +31,10 @@ def test_block_line_statement_with_comment():
output = jinja2_template.render() output = jinja2_template.render()
assert output == "\n2" assert output == "\n2"
def test_add_filter(): def test_add_filter():
texenv.filters["count_caracters"] = lambda x: len(x) texenv.filters["count_caracters"] = lambda x: len(x)
base_template = r"""\Var{a} has \Var{a | count_caracters}""" base_template = r"""\Var{a} has \Var{a | count_caracters}"""
jinja2_template = texenv.from_string(base_template) jinja2_template = texenv.from_string(base_template)
output = jinja2_template.render(a="coucou") output = jinja2_template.render(a="coucou")
assert output == "coucou has 6" assert output == "coucou has 6"

View File

@ -1,9 +1,10 @@
import os import os
from pathlib import Path from pathlib import Path
from bopytex.worker.compile import latexmk
import pytest import pytest
from bopytex.worker.compile import latexmk
@pytest.fixture @pytest.fixture
def tex_path(tmp_path): def tex_path(tmp_path):

View File

@ -1,8 +1,10 @@
import os import os
import jinja2 import jinja2
from bopytex.worker.generate import generate
import pytest import pytest
from bopytex.worker.generate import generate
@pytest.fixture @pytest.fixture
def jinja2_env(tmp_path): def jinja2_env(tmp_path):
@ -70,7 +72,7 @@ def test_generate_with_random(template_path_with_random, jinja2_env):
"jinja2": {"environment": jinja2_env}, "jinja2": {"environment": jinja2_env},
"direct_access": { "direct_access": {
"random": random, "random": random,
} },
}, },
"subject": {}, "subject": {},
}, },

View File

@ -1,10 +1,11 @@
import os import os
import shutil import shutil
from pathlib import Path from pathlib import Path
from bopytex.worker.join_pdf import pdfjam
import pytest import pytest
from bopytex.worker.join_pdf import pdfjam
@pytest.fixture @pytest.fixture
def multiple_pdf(tmp_path, request): def multiple_pdf(tmp_path, request):