Fix: run pre-commit hooks
All checks were successful
continuous-integration/drone/push Build is passing

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

View File

@@ -1,3 +1,4 @@
from bopytex.jinja2_env.texenv import texenv
from bopytex.planner.generate_compile_join_planner import planner
from bopytex.worker import Dispatcher
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.generate import generate
from bopytex.worker.join_pdf import pdfjam
from bopytex.jinja2_env.texenv import texenv
jinja2 = {
"environment": texenv
}
jinja2 = {"environment": texenv}
dispatcher = Dispatcher({
"GENERATE": generate,
"COMPILE": pdflatex,
"JOIN": pdfjam,
"CLEAN": clean,
"ACTIVATE_CORR": activate_corr,
})
dispatcher = Dispatcher(
{
"GENERATE": generate,
"COMPILE": pdflatex,
"JOIN": pdfjam,
"CLEAN": clean,
"ACTIVATE_CORR": activate_corr,
}
)
latex = {
"solution": r"solution/print = true",
"no_solution": r"solution/print = false",
}
"solution": r"solution/print = true",
"no_solution": r"solution/print = false",
}

View File

@@ -1,4 +1,4 @@
class Message():
class Message:
def __init__(self, status, out, err):
self._status = status
self._out = out
@@ -19,6 +19,7 @@ class Message():
def __repr__(self):
return f"Message(status={self.status}, out={self.out}, err={self.err})"
class SubprocessMessage(Message):
def __init__(self, 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 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):
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
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]:
@@ -70,10 +71,7 @@ def tasks_builder(
for subject in subjects:
source = naming.template2source(template, subject)
args = {
"subject": subject,
"options": options
}
args = {"subject": subject, "options": options}
tasks.append(generate(template, args, source))

View File

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

View File

@@ -8,7 +8,7 @@ from bopytex.worker import Dispatcher
class Scheduler:
"""Scheduler is responsible of getting tasks (the tasks) and yield those that can be done"""
def __init__(self, dispatcher:Dispatcher, output_done: list[str] = None):
def __init__(self, dispatcher: Dispatcher, output_done: list[str] = None):
self._dispatcher = dispatcher
if output_done is None:
@@ -73,6 +73,6 @@ class Scheduler:
return message
def backlog(self):
""" Yield tasks sorted according to dependencies """
"""Yield tasks sorted according to dependencies"""
while self.doable_tasks:
yield self.next_task()

View File

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

View File

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

View File

@@ -24,7 +24,7 @@ def generate(template: str, meta: dict, output: str):
)
def activate_corr_on(src: str, meta:dict, output: str):
def activate_corr_on(src: str, meta: dict, output: str):
"""Create a task to activate correction for src"""
return Task(
action="ACTIVATE_CORR",

View File

@@ -15,4 +15,3 @@ class Dispatcher:
)
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))
return Message(0, [f"ACTIVATE CORR - {deps[0]} to {output}"], [])

View File

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

View File

@@ -8,16 +8,16 @@ def generate(args, deps, output):
template = env.get_template(deps[0])
variables = {
"options":args["options"],
"subject":args["subject"],
}
"options": args["options"],
"subject": args["subject"],
}
try:
args["options"]["direct_access"]
except KeyError:
pass
else:
for (k,v) in args["options"]["direct_access"].items():
for (k, v) in args["options"]["direct_access"].items():
if k not in ["options", "subject"]:
variables[k] = v

View File

@@ -18,10 +18,9 @@ def pdfjam(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(
["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"]
+ deps,
["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"] + deps,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,