Compare commits
87 Commits
5f0fc8bc42
...
3c39a42562
Author | SHA1 | Date | |
---|---|---|---|
3c39a42562 | |||
a911b98520 | |||
bf237d77e5 | |||
a8d2fa2ed6 | |||
bde6c11a27 | |||
923cb16c66 | |||
51d4d32849 | |||
251350f30e | |||
62253cb3ba | |||
5efc9a63ea | |||
a0f93cc5b7 | |||
81b64c525c | |||
b2bbc0a24f | |||
cd2fdc162e | |||
d5981d25e5 | |||
8a9b13cfcf | |||
18b4b69139 | |||
d204eb19e1 | |||
b5f7cdb0cf | |||
ae09d37523 | |||
5bf9d8b7c1 | |||
e6595b7041 | |||
67656c2cf1 | |||
37d779c0ab | |||
177128afe2 | |||
b1424f096b | |||
0a40e132c5 | |||
3d54cce718 | |||
473f554ebe | |||
1fd5ca9c96 | |||
8c20ff8e4a | |||
01a0f9db17 | |||
fae2afa76c | |||
b1353bb6c7 | |||
78f6ddc813 | |||
8f1d9cb4d4 | |||
90ae3e936e | |||
e4f234d241 | |||
0d614465f0 | |||
467135abc6 | |||
d9bd4ca5a1 | |||
9d7f779f07 | |||
69b2e1c82e | |||
87ebb4c284 | |||
25b5bde823 | |||
04db450ceb | |||
ca2a47f82a | |||
1fdf223689 | |||
1bcbf2a9a6 | |||
5af4662d43 | |||
fe18dc4ef1 | |||
b455ef23c4 | |||
9c05ef1551 | |||
ca0f498d4e | |||
527ad160cf | |||
ac8fe3dfdd | |||
76a033cf43 | |||
08411bd42d | |||
3f1464f3f6 | |||
abd517b339 | |||
c89959673b | |||
dfcc48dd20 | |||
8c9d7bf9a2 | |||
e52b6eb064 | |||
963348611a | |||
1f0547c1ac | |||
03482d4b3d | |||
dc12a919d0 | |||
374c5f7467 | |||
dca69f94aa | |||
4e7805f40d | |||
7f40b7c38f | |||
f9dd70a2f1 | |||
1865f9ec63 | |||
ebf5bd0c7d | |||
32c74ae679 | |||
4d76dc8992 | |||
211cee2f4f | |||
2b0c325203 | |||
e0377a3e92 | |||
bfe9e6f91e | |||
4dbfe7a82c | |||
480ced3259 | |||
7b64dcf8d6 | |||
6e718b987a | |||
ce98f46bca | |||
083831acdf |
27
.drone.yml
27
.drone.yml
@ -1,13 +1,28 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: Tests
|
||||
image: python:3.10
|
||||
environment:
|
||||
PyPI_TOKEN: pypi_token
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y texlive texlive-extra-utils latexmk
|
||||
- python -m pip install --upgrade pip
|
||||
- python -m pip install poetry
|
||||
- poetry install
|
||||
- poetry run pytest
|
||||
|
||||
- name: Publish
|
||||
image: plugins/pypi
|
||||
settings:
|
||||
username:
|
||||
from_secret: pypi_username
|
||||
password:
|
||||
from_secret: pypi_password
|
||||
image: python:3.10
|
||||
environment:
|
||||
PyPI_TOKEN: pypi_token
|
||||
commands:
|
||||
- python -m pip install --upgrade pip
|
||||
- python -m pip install poetry
|
||||
- poetry config pypi-token.pypi $PyPI_TOKEN
|
||||
- poetry publish --build
|
||||
when:
|
||||
event: tag
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
tests/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
documentation/build/
|
||||
|
20
.pre-commit-config.yaml
Normal file
20
.pre-commit-config.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.6.0
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
- id: isort
|
||||
args: ["--profile", "black"]
|
16
Dockerfile.simple
Normal file
16
Dockerfile.simple
Normal file
@ -0,0 +1,16 @@
|
||||
FROM python:3.11-rc-slim
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y texlive texlive-extra-utils
|
||||
|
||||
RUN apt-get install -y python3-dev
|
||||
COPY requirements.txt /tmp/
|
||||
RUN pip install -r /tmp/requirements.txt
|
||||
|
||||
RUN mkdir -p /src/bopytex
|
||||
COPY bopytex/ /src/bopytex
|
||||
COPY setup.py /src/
|
||||
RUN pip install -e /src
|
||||
|
||||
COPY example/simple /example
|
||||
WORKDIR /example
|
17
Dockerfile.usecase
Normal file
17
Dockerfile.usecase
Normal file
@ -0,0 +1,17 @@
|
||||
FROM python:3.11-rc-slim
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y texlive texlive-extra-utils
|
||||
|
||||
RUN apt-get install -y python3-dev
|
||||
COPY requirements.txt /tmp/
|
||||
RUN pip install -r /tmp/requirements.txt
|
||||
RUN pip install mapytex
|
||||
|
||||
RUN mkdir -p /src/bopytex
|
||||
COPY bopytex/ /src/bopytex
|
||||
COPY setup.py /src/
|
||||
RUN pip install -e /src
|
||||
|
||||
COPY example/usecase /example
|
||||
WORKDIR /example
|
||||
ENV BOPYTEXCONFIG="bopytex_config.py"
|
19
Makefile
Normal file
19
Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
docker-build-simple:
|
||||
docker build -f Dockerfile.simple -t simple .
|
||||
|
||||
docker-simple: docker-build-simple
|
||||
docker run simple sh -c "bopytex -q 2 tpl_example.tex && ls"
|
||||
|
||||
docker-build-usecase:
|
||||
docker build -f Dockerfile.usecase -t usecase .
|
||||
|
||||
docker-usecase: docker-build-usecase
|
||||
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat 1_example.tex"
|
||||
|
||||
usecase-example: docker-build-usecase
|
||||
docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat joined_example.pdf" > example/usecase/joined_example.pdf
|
||||
|
||||
simple-example: docker-build-simple
|
||||
docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat joined_example.pdf" > example/simple/joined_example.pdf
|
||||
|
||||
examples: usecase-example simple-example
|
171
README.md
171
README.md
@ -2,94 +2,149 @@
|
||||
|
||||
[](https://drone.opytex.org/lafrite/Bopytex)
|
||||
|
||||
Bopytex is a command line tool for producing random math exercises with their correction. It embeds [mapytex](https://git.opytex.org/lafrite/Mapytex) and [python](python.org) into [latex](latex-project.org) through [jinja](jinja.pocoo.org).
|
||||
Bopytex is a command line tool which embed python into latex. It uses jinja2 to do so with a modified environnement to match with latex syntax.
|
||||
|
||||
## Installing
|
||||
|
||||
Bopytex depends on `texlive` and `textlive-extra-utils` (for latexmk and pdfjoin)
|
||||
|
||||
Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/)
|
||||
|
||||
pip install -U bopytex
|
||||
|
||||
## Simple example
|
||||
|
||||
Let's say I want an exercise on adding 2 fractions (files are in `examples`).
|
||||
``` latex
|
||||
% save this as tpl_simple.tex
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
The *latex* template called `tpl_add_fraction.tex`
|
||||
\title{Bopytex example -- {{ number }}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
%- set a = 10
|
||||
%- set n = 2
|
||||
We have two variables
|
||||
\begin{itemize}
|
||||
\item a: \Var{a}
|
||||
\item n: \Var{n}
|
||||
\end{itemize}
|
||||
|
||||
\section{Variables}
|
||||
\subsection{subject}
|
||||
\begin{itemize}
|
||||
%- for k,v in subject.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
\subsection{options}
|
||||
\begin{itemize}
|
||||
%- for k,v in options.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
|
||||
\end{document}
|
||||
|
||||
```
|
||||
|
||||
The following command produces the [joined_example.pdf](./example/simple/joined_example.pdf) document
|
||||
|
||||
``` bash
|
||||
$ bopytex tpl_simple.tex
|
||||
```
|
||||
|
||||
## How I use it
|
||||
|
||||
I build this program to produce individual exams subjects for each of my student with the correction associated. I write a template, and bopytex build subject and correction.
|
||||
|
||||
To produce formulas and values, I use an another tool I an developing: `mapytex <https://git.opytex.org/lafrite/Mapytex`. I am importing it through `bopytex_config.py`.
|
||||
|
||||
``` python
|
||||
# bopytex_config.py
|
||||
from mapytex import Expression
|
||||
|
||||
random.seed(0) # Controlling the seed allows to make subject reproductible
|
||||
|
||||
direct_access = {
|
||||
"Expression": Expression,
|
||||
}
|
||||
```
|
||||
|
||||
Every variables, objects or function inside this file will be available inside the template.
|
||||
|
||||
``` latex
|
||||
% tpl_example.tpl
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\title{Bopytex with Mapytex example -- \Var{ subject.name }}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\section{Ajouts de fractions}
|
||||
\maketitle
|
||||
|
||||
Adding two fractions
|
||||
%- set e = Expression.random("{a} / {b} + {c} / {k*b}", ["b > 1", "k>1"])
|
||||
\[
|
||||
A = \Var{e}
|
||||
\]
|
||||
Solution
|
||||
\[
|
||||
\Var{e.simplify().explain() | join('=')}
|
||||
\]
|
||||
\end{document}
|
||||
```
|
||||
%- set e = Expression.random("{a} + {b}")
|
||||
\Var{e}
|
||||
|
||||
Generate latex files and compile those for 2 different subjects.
|
||||
\Var{e.simplify()}
|
||||
|
||||
```
|
||||
bopytex -t tpl_add_fractions.tex -N 2
|
||||
```
|
||||
|
||||
It produces 2 sources files
|
||||
|
||||
- `01_add_fractions.tex`
|
||||
|
||||
```latex
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\section{Ajouts de fractions}
|
||||
|
||||
Adding two fractions
|
||||
\[
|
||||
A = \frac{- 2}{4} + \frac{7}{8}
|
||||
\]
|
||||
Solution
|
||||
\[
|
||||
\frac{- 2}{4} + \frac{7}{8}=\frac{- 2 \times 2}{4 \times 2} + \frac{7}{8}=\frac{- 4}{8} + \frac{7}{8}=\frac{- 4 + 7}{8}=\frac{3}{8}
|
||||
\]
|
||||
\section{Variables}
|
||||
\subsection{subject}
|
||||
\begin{itemize}
|
||||
%- for k,v in subject.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
\subsection{options}
|
||||
\begin{itemize}
|
||||
%- for k,v in options.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
|
||||
\end{document}
|
||||
```
|
||||
|
||||
- `02_add_fractions.tex`
|
||||
Information about my students are stored in a csv file (here `students.csv`)
|
||||
|
||||
```latex
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\section{Ajouts de fractions}
|
||||
|
||||
Adding two fractions
|
||||
\[
|
||||
A = \frac{8}{9} + \frac{3}{63}
|
||||
\]
|
||||
Solution
|
||||
\[
|
||||
\frac{8}{9} + \frac{3}{63}=\frac{8 \times 7}{9 \times 7} + \frac{3}{63}=\frac{56}{63} + \frac{3}{63}=\frac{56 + 3}{63}=\frac{59}{63}
|
||||
\]
|
||||
|
||||
\end{document}
|
||||
``` csv
|
||||
"Name","Age","Email","fraction level","calculus level"
|
||||
"Spike Tucker","22","s.tucker@randatmail.com","7","3"
|
||||
"Martin Payne","21","m.payne@randatmail.com","7","3"
|
||||
"Kimberly Baker","20","k.baker@randatmail.com","1","8"
|
||||
"Emma Bailey","29","e.bailey@randatmail.com","2","5"
|
||||
"Nicholas Taylor","28","n.taylor@randatmail.com","3","3"
|
||||
```
|
||||
|
||||
And a ready to print pdf.
|
||||
Then I can produce a [subject for each of my student](./example/usecase/joined_example.pdf)
|
||||
|
||||
- [ all_add_fraction.pdf ]( ./examples/all_add_fraction.pdf )
|
||||
``` bash
|
||||
$ bopytex tpl_simple.tex -s students.csv -c bopytex_config.py
|
||||
```
|
||||
|
||||
|
||||
## Running examples
|
||||
|
||||
I build two examples base of the simple example and how I use it. They are playable through dockerfiles with make commands.
|
||||
|
||||
For the simple example
|
||||
|
||||
make docker-simple
|
||||
|
||||
For how I use it
|
||||
|
||||
make docker-usecase
|
||||
|
@ -1,10 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
#from .bopytex import subject_metadatas, crazy_feed, pdfjoin
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
|
250
bopytex/bopytex.py
Executable file → Normal file
250
bopytex/bopytex.py
Executable file → Normal file
@ -1,248 +1,2 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Producing then compiling templates
|
||||
"""
|
||||
|
||||
import csv
|
||||
import os
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
import pytex
|
||||
#from mapytex import Expression, Integer, Decimal, random_list
|
||||
import mapytex
|
||||
import bopytex.filters as filters
|
||||
|
||||
formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")
|
||||
steam_handler = logging.StreamHandler()
|
||||
steam_handler.setLevel(logging.DEBUG)
|
||||
steam_handler.setFormatter(formatter)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.addHandler(steam_handler)
|
||||
|
||||
|
||||
def setup():
|
||||
mapytex.Expression.set_render("tex")
|
||||
logger.debug(f"Render for Expression is {mapytex.Expression.RENDER}")
|
||||
mapytex_tools = {
|
||||
"Expression": mapytex.Expression,
|
||||
"Integer": mapytex.Integer,
|
||||
"Decimal": mapytex.Decimal,
|
||||
"random_list": mapytex.random_list,
|
||||
"random_pythagore": mapytex.random_pythagore,
|
||||
"Dataset": mapytex.Dataset,
|
||||
"WeightedDataset": mapytex.WeightedDataset,
|
||||
}
|
||||
pytex.update_export_dict(mapytex_tools)
|
||||
|
||||
pytex.add_filter("calculus", filters.do_calculus)
|
||||
|
||||
|
||||
def get_working_dir(options):
|
||||
""" Get the working directory """
|
||||
if options["working_dir"]:
|
||||
working_dir = Path(options["working_dir"])
|
||||
else:
|
||||
try:
|
||||
template = Path(options["template"])
|
||||
except TypeError:
|
||||
raise ValueError(
|
||||
"Need to set the working directory \
|
||||
or to give a template"
|
||||
)
|
||||
else:
|
||||
working_dir = template.parent
|
||||
logger.debug(f"The output directory will be {working_dir}")
|
||||
return working_dir
|
||||
|
||||
|
||||
def activate_printanswers(
|
||||
texfile,
|
||||
noans=r"%\printsolutionstype{exercise}",
|
||||
ans=r"\printsolutionstype{exercise}",
|
||||
corr_prefix="corr_"
|
||||
):
|
||||
""" Activate printanswers mod in texfile
|
||||
|
||||
:param texfile: path to the latex file
|
||||
:param noans: string that prevent printing solution
|
||||
:param ans: string that activate printing solution
|
||||
:param corr_prefix: correction file prefix
|
||||
"""
|
||||
output_fname = corr_prefix + texfile
|
||||
with open(texfile, "r") as input_f:
|
||||
with open(output_fname, "w") as output_f:
|
||||
for line in input_f.readlines():
|
||||
output_f.write(line.replace(noans, ans))
|
||||
return output_fname
|
||||
|
||||
|
||||
def deactivate_printanswers(corr_fname):
|
||||
""" Activate printanswers mod in texfile """
|
||||
Path(corr_fname).remove()
|
||||
|
||||
|
||||
def pdfjoin(pdf_files, destname, working_dir=".", rm_pdfs=1):
|
||||
"""TODO: Docstring for pdfjoin.
|
||||
|
||||
:param pdf_files: list of pdf files to join
|
||||
:param destname: name for joined pdf
|
||||
:param working_dir: the working directory
|
||||
:param rm_pdfs: Remove pdf_files after joining them
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
joined_pdfs = Path(working_dir) / Path(destname)
|
||||
pdf_files_str = " ".join(pdf_files)
|
||||
pdfjam = f"pdfjam {pdf_files_str} -o {joined_pdfs}"
|
||||
logger.debug(f"Run {pdfjam}")
|
||||
logger.info("Joining pdf files")
|
||||
os.system(pdfjam)
|
||||
if rm_pdfs:
|
||||
logger.info(f"Remove {pdf_files_str}")
|
||||
os.system(f"rm {pdf_files_str}")
|
||||
|
||||
|
||||
def extract_student_csv(csv_filename):
|
||||
""" Extract student list from csv_filename """
|
||||
with open(csv_filename, "r") as csvfile:
|
||||
reader = csv.DictReader(csvfile)
|
||||
return [r for r in reader]
|
||||
|
||||
|
||||
def subject_metadatas(options):
|
||||
""" Return metadata on subject to produce
|
||||
|
||||
if csv is given it will based on is
|
||||
otherwise it will be based on quantity
|
||||
|
||||
:example:
|
||||
>>> subject_metadata(10)
|
||||
"""
|
||||
if options["students_csv"]:
|
||||
metadatas = []
|
||||
for (i, s) in enumerate(extract_student_csv(options["students_csv"])):
|
||||
d = {"num": f"{i+1:02d}"}
|
||||
d.update(s)
|
||||
metadatas.append(d)
|
||||
elif options["number_subjects"] > 0:
|
||||
metadatas = [{"num": f"{i+1:02d}"}
|
||||
for i in range(options["number_subjects"])]
|
||||
else:
|
||||
raise ValueError("Need metacsv or quantity to build subject metadata")
|
||||
|
||||
for meta in metadatas:
|
||||
meta.update(
|
||||
{
|
||||
"template": str(Path(options["template"]).name),
|
||||
"texfile": str(Path(options["template"]).name).replace(
|
||||
"tpl", meta["num"]
|
||||
),
|
||||
"directory": str(Path(options["template"]).parent),
|
||||
}
|
||||
)
|
||||
|
||||
return metadatas
|
||||
|
||||
|
||||
def feed(*args, **kwrds):
|
||||
""" Nice and smooth pytex feed """
|
||||
pytex.feed(*args, **kwrds)
|
||||
|
||||
|
||||
def crazy_feed(*args, **kwrds):
|
||||
""" Crazy mod for pytex feed """
|
||||
while True:
|
||||
try:
|
||||
pytex.feed(*args, **kwrds)
|
||||
except:
|
||||
logger.debug(f"Crazy feed is working hard...! {args} {kwrds}")
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
def clean(directory):
|
||||
pytex.clean(directory)
|
||||
|
||||
|
||||
def texcompile(filename):
|
||||
logger.debug(f"Start compiling {filename}")
|
||||
pytex.pdflatex(Path(filename))
|
||||
logger.debug(f"End compiling")
|
||||
|
||||
|
||||
def produce_and_compile(options):
|
||||
""" Produce and compile subjects
|
||||
"""
|
||||
logger.debug(f"CI parser gets {options}")
|
||||
|
||||
template = Path(options["template"]).name
|
||||
directory = Path(options["template"]).parent
|
||||
metadatas = subject_metadatas(options)
|
||||
logger.debug(f"Metadata {metadatas}")
|
||||
|
||||
for meta in metadatas:
|
||||
logger.debug(f"Feeding template toward {meta['texfile']}")
|
||||
if options["crazy"]:
|
||||
crazy_feed(
|
||||
template=Path(meta["directory"]) / meta["template"],
|
||||
data=meta,
|
||||
output=meta["texfile"],
|
||||
force=1,
|
||||
)
|
||||
else:
|
||||
feed(
|
||||
template=Path(meta["directory"]) / meta["template"],
|
||||
data=meta,
|
||||
output=meta["texfile"],
|
||||
force=1,
|
||||
)
|
||||
assert(Path(meta["texfile"]).exists())
|
||||
logger.debug(f"{meta['texfile']} fed")
|
||||
|
||||
if options["corr"]:
|
||||
logger.debug(f"Building correction for {meta['texfile']}")
|
||||
meta.update({
|
||||
"corr_texfile": activate_printanswers(meta["texfile"]),
|
||||
})
|
||||
|
||||
if not options["no_compile"]:
|
||||
for prefix in ["", "corr_"]:
|
||||
key = prefix + "texfile"
|
||||
try:
|
||||
meta[key]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
texcompile(meta[key])
|
||||
meta.update({
|
||||
prefix+'pdffile': meta[key].replace('tex', 'pdf')
|
||||
})
|
||||
|
||||
if not options["no_join"]:
|
||||
for prefix in ["", "corr_"]:
|
||||
key = prefix + "pdffile"
|
||||
try:
|
||||
pdfs = [m[key] for m in metadatas]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
pdfjoin(
|
||||
pdfs,
|
||||
template.replace(
|
||||
"tpl", prefix+"all").replace(".tex", ".pdf"),
|
||||
directory,
|
||||
rm_pdfs=1,
|
||||
)
|
||||
|
||||
if not options["dirty"]:
|
||||
clean(directory)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
import bopytex.default_config as DEFAULT
|
||||
from bopytex.service import orcherstrator
|
||||
|
25
bopytex/default_config.py
Normal file
25
bopytex/default_config.py
Normal file
@ -0,0 +1,25 @@
|
||||
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
|
||||
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
|
||||
|
||||
jinja2 = {"environment": texenv}
|
||||
|
||||
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",
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Custom filter for Bopytex
|
||||
"""
|
||||
|
||||
__all__ = ["do_calculus"]
|
||||
|
||||
def do_calculus(steps, name="A", sep="=", end="", joining=" \\\\ \n"):
|
||||
"""Display properly the calculus
|
||||
|
||||
Generate this form string:
|
||||
"name & sep & a_step end joining"
|
||||
|
||||
:param steps: list of steps
|
||||
:returns: latex string ready to be endbeded
|
||||
|
||||
|
||||
"""
|
||||
|
||||
ans = joining.join([
|
||||
name + " & "
|
||||
+ sep + " & "
|
||||
+ str(s) + end for s in steps
|
||||
])
|
||||
return ans
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
31
bopytex/jinja2_env/texenv.py
Normal file
31
bopytex/jinja2_env/texenv.py
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import jinja2
|
||||
|
||||
__all__ = [
|
||||
"texenv",
|
||||
]
|
||||
|
||||
# Definition of jinja syntax for latex
|
||||
texenv = jinja2.Environment(
|
||||
block_start_string=r"\Block{",
|
||||
block_end_string="}",
|
||||
variable_start_string=r"\Var{",
|
||||
variable_end_string="}",
|
||||
comment_start_string=r"\#{",
|
||||
comment_end_string="}",
|
||||
line_statement_prefix="%-",
|
||||
line_comment_prefix="%#",
|
||||
loader=jinja2.ChoiceLoader(
|
||||
[
|
||||
jinja2.FileSystemLoader(["./"]),
|
||||
]
|
||||
),
|
||||
extensions=["jinja2.ext.do"],
|
||||
)
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from random import randint
|
||||
|
||||
def pythagore_triplet(v_min = 1, v_max = 10):
|
||||
"""Random pythagore triplet generator
|
||||
|
||||
:param v_min: minimum in randint
|
||||
:param v_max: max in randint
|
||||
:returns: (a,b,c) such that a^2 + b^2 = c^2
|
||||
|
||||
"""
|
||||
u = randint(v_min,v_max)
|
||||
v = randint(v_min,v_max)
|
||||
while v == u:
|
||||
v = randint(v_min,v_max)
|
||||
|
||||
u, v = max(u,v), min(u,v)
|
||||
|
||||
return (u**2-v**2 , 2*u*v, u**2 + v**2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(pythagore_triplet())
|
||||
|
||||
for j in range(1,10):
|
||||
for i in range(j,10):
|
||||
print((i**2-j**2 , 2*i*j, i**2 + j**2))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
@ -1,33 +0,0 @@
|
||||
\Block{macro solveEquation(P)}
|
||||
|
||||
On commence par calculer le discriminant de $P(x) = \Var{P}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{P.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if P.delta > 0}
|
||||
comme $\Delta = \Var{P.delta} > 0$ donc $P$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-P.b} - \sqrt{\Var{P.delta}}}{2 \times \Var{P.a}} = \Var{P.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P.b} + \sqrt{\Var{P.delta}}}{2 \times \Var{P.a}} = \Var{P.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions de l'équation $\Var{P} = 0$ sont donc $\mathcal{S} = \left\{ \Var{P.roots()[0]}; \Var{P.roots()[1]} \right\}$
|
||||
|
||||
\Block{elif P.delta == 0}
|
||||
Comme $\Delta = 0$ donc $P$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \frac{-\Var{P.b}}{2\times \Var{P.a}} = \Var{P.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
La solution de $\Var{P} = 0$ est donc $\mathcal{S} = \left\{ \Var{P.roots()[0]}\right\}$
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{P.delta} < 0$ donc $P$ n'a pas de racine donc l'équation $\Var{P} = 0$ n'a pas de solution.
|
||||
|
||||
\Block{endif}
|
||||
|
||||
\Block{endmacro}
|
37
bopytex/message.py
Normal file
37
bopytex/message.py
Normal file
@ -0,0 +1,37 @@
|
||||
class Message:
|
||||
def __init__(self, status, out, err):
|
||||
self._status = status
|
||||
self._out = out
|
||||
self._err = err
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
return self._status
|
||||
|
||||
@property
|
||||
def out(self):
|
||||
return self._out
|
||||
|
||||
@property
|
||||
def err(self):
|
||||
return self._err
|
||||
|
||||
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
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
return self._process.wait()
|
||||
|
||||
@property
|
||||
def out(self):
|
||||
return self._process.stdout
|
||||
|
||||
@property
|
||||
def err(self):
|
||||
return self._process.stderr
|
0
bopytex/planner/__init__.py
Normal file
0
bopytex/planner/__init__.py
Normal file
59
bopytex/planner/activate_corr_compile_join_planner.py
Normal file
59
bopytex/planner/activate_corr_compile_join_planner.py
Normal file
@ -0,0 +1,59 @@
|
||||
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 = []
|
||||
for file in os.listdir(dir):
|
||||
if accept(file) and not reject(file):
|
||||
files.append(file)
|
||||
return files
|
||||
|
||||
|
||||
def planner(options: dict) -> list[Task]:
|
||||
sources = list_files(
|
||||
accept=lambda x: x.endswith(".tex"),
|
||||
reject=lambda x: x.startswith("tpl_"),
|
||||
)
|
||||
options["sources"] = sources
|
||||
return tasks_builder(options)
|
||||
|
||||
|
||||
def tasks_builder(
|
||||
options: dict,
|
||||
) -> list[Task]:
|
||||
opt = {
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
}
|
||||
opt.update(options)
|
||||
|
||||
try:
|
||||
sources = opt["sources"]
|
||||
no_join = opt["no_join"]
|
||||
no_pdf = opt["no_pdf"]
|
||||
except KeyError:
|
||||
raise PlannerMissingOption("An option is missing")
|
||||
|
||||
tasks = []
|
||||
corr_pdfs = []
|
||||
|
||||
for source in sources:
|
||||
corr_source = naming.corr(source)
|
||||
tasks.append(activate_corr_on(source, opt, corr_source))
|
||||
|
||||
if not no_pdf:
|
||||
corr_pdf = naming.source2pdf(corr_source)
|
||||
tasks.append(compile_pdf(corr_source, corr_pdf))
|
||||
corr_pdfs.append(corr_pdf)
|
||||
|
||||
if not no_join:
|
||||
joined = "joined.pdf"
|
||||
|
||||
if corr_pdfs:
|
||||
corr_joined = naming.corr(joined)
|
||||
tasks.append(join_pdfs(corr_pdfs, corr_joined))
|
||||
|
||||
return tasks
|
2
bopytex/planner/exceptions.py
Normal file
2
bopytex/planner/exceptions.py
Normal file
@ -0,0 +1,2 @@
|
||||
class PlannerMissingOption(Exception):
|
||||
pass
|
9
bopytex/planner/fake_planner.py
Normal file
9
bopytex/planner/fake_planner.py
Normal file
@ -0,0 +1,9 @@
|
||||
from bopytex.tasks import Task
|
||||
|
||||
|
||||
def simple(options: dict) -> list[Task]:
|
||||
"""Simple planner with options['quantity'] tasks and no dependencies"""
|
||||
return [
|
||||
Task("DO", args={"number": i}, deps=[], output=f"{i}")
|
||||
for i in range(options["quantity"])
|
||||
]
|
101
bopytex/planner/generate_compile_join_planner.py
Normal file
101
bopytex/planner/generate_compile_join_planner.py
Normal file
@ -0,0 +1,101 @@
|
||||
import csv
|
||||
|
||||
import bopytex.planner.naming as naming
|
||||
from bopytex.planner.exceptions import PlannerMissingOption
|
||||
from bopytex.tasks import Task, activate_corr_on, compile_pdf, generate, join_pdfs
|
||||
|
||||
|
||||
def build_subject_list_from_infos(infos: list[dict]) -> list[dict]:
|
||||
subjects = []
|
||||
digit = len(str(len(infos)))
|
||||
for i, infos in enumerate(infos):
|
||||
subjects.append({"number": str(i + 1).zfill(digit), **infos})
|
||||
return subjects
|
||||
|
||||
|
||||
def build_subject_list_from_qty(qty: int) -> list[dict]:
|
||||
subjects = []
|
||||
digit = len(str(qty))
|
||||
for i in range(qty):
|
||||
subjects.append({"number": str(i + 1).zfill(digit)})
|
||||
return subjects
|
||||
|
||||
|
||||
def planner(options: dict) -> list[Task]:
|
||||
try:
|
||||
students_csv = options["students_csv"]
|
||||
assert options["students_csv"] != ""
|
||||
|
||||
except (KeyError, AssertionError):
|
||||
try:
|
||||
quantity_subjects = options["quantity_subjects"]
|
||||
assert options["quantity_subjects"] != 0
|
||||
except (KeyError, AssertionError):
|
||||
raise PlannerMissingOption("students_csv or quantity_subjects is required")
|
||||
else:
|
||||
options["subjects"] = build_subject_list_from_qty(qty=quantity_subjects)
|
||||
|
||||
else:
|
||||
with open(students_csv, "r") as csv_file:
|
||||
reader = csv.DictReader(csv_file)
|
||||
infos = [r for r in reader]
|
||||
options["subjects"] = build_subject_list_from_infos(infos)
|
||||
|
||||
return tasks_builder(options)
|
||||
|
||||
|
||||
def tasks_builder(
|
||||
options: dict,
|
||||
) -> list[Task]:
|
||||
|
||||
opt = {
|
||||
"corr": False,
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
}
|
||||
opt.update(options)
|
||||
|
||||
try:
|
||||
template = opt["template"]
|
||||
subjects = opt["subjects"]
|
||||
corr = opt["corr"]
|
||||
no_join = opt["no_join"]
|
||||
no_pdf = opt["no_pdf"]
|
||||
except KeyError:
|
||||
raise PlannerMissingOption("An option is missing")
|
||||
|
||||
tasks = []
|
||||
|
||||
pdfs = []
|
||||
corr_pdfs = []
|
||||
|
||||
for subject in subjects:
|
||||
source = naming.template2source(template, subject)
|
||||
args = {"subject": subject, "options": options}
|
||||
|
||||
tasks.append(generate(template, args, source))
|
||||
|
||||
if not no_pdf:
|
||||
pdf = naming.source2pdf(source)
|
||||
tasks.append(compile_pdf(source, pdf))
|
||||
pdfs.append(pdf)
|
||||
|
||||
if corr:
|
||||
corr_source = naming.corr(source)
|
||||
tasks.append(activate_corr_on(source, opt, corr_source))
|
||||
|
||||
if not no_pdf:
|
||||
corr_pdf = naming.source2pdf(corr_source)
|
||||
tasks.append(compile_pdf(corr_source, corr_pdf))
|
||||
corr_pdfs.append(corr_pdf)
|
||||
|
||||
if not no_join:
|
||||
joined = naming.join(template)
|
||||
if pdfs:
|
||||
tasks.append(join_pdfs(pdfs, joined))
|
||||
|
||||
if corr_pdfs:
|
||||
corr_joined = naming.corr(joined)
|
||||
tasks.append(join_pdfs(corr_pdfs, corr_joined))
|
||||
|
||||
return tasks
|
14
bopytex/planner/naming.py
Normal file
14
bopytex/planner/naming.py
Normal file
@ -0,0 +1,14 @@
|
||||
def template2source(template: str, metadatas: dict):
|
||||
return metadatas["number"] + template[3:]
|
||||
|
||||
|
||||
def corr(source):
|
||||
return "corr_" + source
|
||||
|
||||
|
||||
def source2pdf(source):
|
||||
return source[:-4] + ".pdf"
|
||||
|
||||
|
||||
def join(template):
|
||||
return source2pdf("joined" + template[3:])
|
78
bopytex/scheduler.py
Normal file
78
bopytex/scheduler.py
Normal file
@ -0,0 +1,78 @@
|
||||
""" Scheduler for action to make """
|
||||
|
||||
|
||||
from bopytex.tasks import Task
|
||||
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):
|
||||
self._dispatcher = dispatcher
|
||||
|
||||
if output_done is None:
|
||||
self._output_done = []
|
||||
else:
|
||||
self._output_done = output_done
|
||||
|
||||
self._tasks = []
|
||||
self._failed_tasks = []
|
||||
|
||||
@property
|
||||
def tasks(self) -> list[Task]:
|
||||
"""List all the tasks todo"""
|
||||
return self._tasks
|
||||
|
||||
@property
|
||||
def doable_tasks(self) -> list[Task]:
|
||||
"""List all doable tasks"""
|
||||
return [
|
||||
task
|
||||
for task in self.tasks
|
||||
if not task.deps or all([d in self.output_done for d in task.deps])
|
||||
]
|
||||
|
||||
@property
|
||||
def all_deps(self) -> set[str]:
|
||||
"""List dependencies of all tasks"""
|
||||
return {d for task in self.tasks for d in task.deps}
|
||||
|
||||
@property
|
||||
def all_output(self) -> set[str]:
|
||||
"""List ouput of all tasks"""
|
||||
return {task.output for task in self.tasks}
|
||||
|
||||
@property
|
||||
def output_done(self) -> list[str]:
|
||||
return self._output_done
|
||||
|
||||
@property
|
||||
def failed_tasks(self) -> list[Task]:
|
||||
return self._failed_tasks
|
||||
|
||||
def append(self, tasks: list[Task]):
|
||||
self._tasks += tasks
|
||||
|
||||
def is_finishable(self):
|
||||
return self.all_deps.issubset(self.all_output)
|
||||
|
||||
def next_task(self):
|
||||
try:
|
||||
task = self.doable_tasks[0]
|
||||
except IndexError:
|
||||
raise StopIteration
|
||||
|
||||
self._tasks.remove(task)
|
||||
message = self._dispatcher(task)
|
||||
if message.status == 0:
|
||||
self._output_done.append(task.output)
|
||||
else:
|
||||
self._failed_tasks.append(task)
|
||||
|
||||
return message
|
||||
|
||||
def backlog(self):
|
||||
"""Yield tasks sorted according to dependencies"""
|
||||
while self.doable_tasks:
|
||||
yield self.next_task()
|
@ -2,10 +2,11 @@
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
import click
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from .bopytex import subject_metadatas, crazy_feed, pdfjoin, feed, clean, texcompile, setup, activate_printanswers
|
||||
|
||||
import click
|
||||
|
||||
from bopytex.service import main
|
||||
|
||||
formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")
|
||||
steam_handler = logging.StreamHandler()
|
||||
@ -21,11 +22,11 @@ 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",
|
||||
"--working-dir",
|
||||
default=".",
|
||||
type=click.Path(exists=True),
|
||||
)
|
||||
@click.option(
|
||||
@ -35,9 +36,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",
|
||||
@ -46,11 +44,18 @@ logger.addHandler(steam_handler)
|
||||
help="Do not compile source code",
|
||||
)
|
||||
@click.option(
|
||||
"-N",
|
||||
"--number_subjects",
|
||||
"-d",
|
||||
"--dirty",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Do not clean after compilation",
|
||||
)
|
||||
@click.option(
|
||||
"-q",
|
||||
"--quantity_subjects",
|
||||
type=int,
|
||||
default=1,
|
||||
help="The number of subjects to make",
|
||||
help="The quantity of subjects to make",
|
||||
)
|
||||
@click.option(
|
||||
"-j",
|
||||
@ -67,96 +72,28 @@ logger.addHandler(steam_handler)
|
||||
help="Activate correction and compile only from existing subjects",
|
||||
)
|
||||
@click.option(
|
||||
"-c",
|
||||
"-C",
|
||||
"--corr",
|
||||
is_flag=True,
|
||||
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!",
|
||||
"-c",
|
||||
"--configfile",
|
||||
type=str,
|
||||
default="bopyptex_config.py",
|
||||
help="Config file path",
|
||||
)
|
||||
def new(**options):
|
||||
""" Bopytex
|
||||
|
||||
Feed the template (tpl_...) and then compile it with latex.
|
||||
|
||||
"""
|
||||
setup()
|
||||
|
||||
logger.debug(f"CI parser gets {options}")
|
||||
|
||||
template = Path(options["template"]).name
|
||||
directory = Path(options["template"]).parent
|
||||
metadatas = subject_metadatas(options)
|
||||
logger.debug(f"Metadata {metadatas}")
|
||||
|
||||
for meta in metadatas:
|
||||
if not options["only_corr"]:
|
||||
logger.debug(f"Feeding template toward {meta['texfile']}")
|
||||
if options["crazy"]:
|
||||
crazy_feed(
|
||||
template=Path(meta["directory"]) / meta["template"],
|
||||
data=meta,
|
||||
output=meta["texfile"],
|
||||
force=1,
|
||||
)
|
||||
else:
|
||||
feed(
|
||||
template=Path(meta["directory"]) / meta["template"],
|
||||
data=meta,
|
||||
output=meta["texfile"],
|
||||
force=1,
|
||||
)
|
||||
assert(Path(meta["texfile"]).exists())
|
||||
logger.debug(f"{meta['texfile']} fed")
|
||||
|
||||
if options["corr"] or options["only_corr"]:
|
||||
logger.debug(f"Building correction for {meta['texfile']}")
|
||||
meta.update({
|
||||
"corr_texfile": activate_printanswers(meta["texfile"]),
|
||||
})
|
||||
|
||||
if not options["no_compile"]:
|
||||
if options["only_corr"]:
|
||||
to_compile = ["corr_"]
|
||||
else:
|
||||
to_compile = ["", "corr_"]
|
||||
|
||||
for prefix in to_compile:
|
||||
key = prefix + "texfile"
|
||||
try:
|
||||
meta[key]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
texcompile(meta[key])
|
||||
meta.update({
|
||||
prefix+'pdffile': meta[key].replace('tex', 'pdf')
|
||||
})
|
||||
|
||||
if not options["no_join"]:
|
||||
for prefix in ["", "corr_"]:
|
||||
key = prefix + "pdffile"
|
||||
try:
|
||||
pdfs = [m[key] for m in metadatas]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
pdfjoin(
|
||||
pdfs,
|
||||
template.replace(
|
||||
"tpl", prefix+"all").replace(".tex", ".pdf"),
|
||||
directory,
|
||||
rm_pdfs=1,
|
||||
)
|
||||
|
||||
if not options["dirty"]:
|
||||
clean(directory)
|
||||
for message in main(**options):
|
||||
try:
|
||||
assert message.status == 0
|
||||
except AssertionError:
|
||||
logger.warning(message)
|
||||
break
|
||||
else:
|
||||
logger.info(message.out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
100
bopytex/service.py
Executable file
100
bopytex/service.py
Executable file
@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
Producing then compiling templates
|
||||
"""
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from bopytex import default_config
|
||||
from bopytex.scheduler import Scheduler
|
||||
|
||||
|
||||
def orcherstrator(
|
||||
options: dict,
|
||||
planner,
|
||||
dispatcher,
|
||||
):
|
||||
tasks = planner(options)
|
||||
|
||||
scheduler = Scheduler(dispatcher, [options["template"]])
|
||||
scheduler.append(tasks)
|
||||
|
||||
for message in scheduler.backlog():
|
||||
yield message
|
||||
|
||||
|
||||
def load_module(modulefile: str):
|
||||
spec = importlib.util.spec_from_file_location("module.name", modulefile)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def clean_vars_keys(
|
||||
vars: dict,
|
||||
keys: list[str] = [
|
||||
"__name__",
|
||||
"__doc__",
|
||||
"__package__",
|
||||
"__loader__",
|
||||
"__spec__",
|
||||
"__file__",
|
||||
"__cached__",
|
||||
"__builtins__",
|
||||
],
|
||||
) -> dict:
|
||||
new_dict = vars.copy()
|
||||
for k in keys:
|
||||
del new_dict[k]
|
||||
return new_dict
|
||||
|
||||
|
||||
def config_from_file(filename: str) -> dict:
|
||||
if Path(filename).exists():
|
||||
local_config = vars(load_module(filename))
|
||||
return clean_vars_keys(local_config)
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
def build_config(options: dict) -> dict:
|
||||
"""Look for options["configfile"] to load it with default_config and options"""
|
||||
config = clean_vars_keys(vars(default_config))
|
||||
|
||||
configfile = ""
|
||||
try:
|
||||
configfile = options["configfile"]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
configfile = os.environ["BOPYTEXCONFIG"]
|
||||
except KeyError:
|
||||
pass
|
||||
if configfile:
|
||||
local_config = config_from_file(configfile)
|
||||
config.update(local_config)
|
||||
|
||||
config.update(options)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def main(**options):
|
||||
|
||||
config = build_config(options)
|
||||
|
||||
orcherstre = orcherstrator(
|
||||
config, planner=default_config.planner, dispatcher=default_config.dispatcher
|
||||
)
|
||||
for message in orcherstre:
|
||||
yield message
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
64
bopytex/tasks.py
Normal file
64
bopytex/tasks.py
Normal file
@ -0,0 +1,64 @@
|
||||
""" Produce tasks to do
|
||||
|
||||
It essentially place things at the right place.
|
||||
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Task:
|
||||
action: str
|
||||
args: dict
|
||||
deps: list
|
||||
output: str
|
||||
|
||||
|
||||
def generate(template: str, meta: dict, output: str):
|
||||
"""Create a task to generate a subject"""
|
||||
return Task(
|
||||
action="GENERATE",
|
||||
args=meta,
|
||||
deps=[template],
|
||||
output=output,
|
||||
)
|
||||
|
||||
|
||||
def activate_corr_on(src: str, meta: dict, output: str):
|
||||
"""Create a task to activate correction for src"""
|
||||
return Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args=meta,
|
||||
deps=[src],
|
||||
output=output,
|
||||
)
|
||||
|
||||
|
||||
def compile_pdf(src: str, output: str):
|
||||
"""Create a task to compile src"""
|
||||
return Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=[src],
|
||||
output=output,
|
||||
)
|
||||
|
||||
|
||||
def join_pdfs(pdfs: list, output: str):
|
||||
"""Create task to join pdf together"""
|
||||
return Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=pdfs,
|
||||
output=output,
|
||||
)
|
||||
|
||||
|
||||
def clean(files: list):
|
||||
"""Create task to clean files"""
|
||||
return Task(
|
||||
action="CLEAN",
|
||||
args={},
|
||||
deps=files,
|
||||
output=None,
|
||||
)
|
17
bopytex/worker/__init__.py
Normal file
17
bopytex/worker/__init__.py
Normal file
@ -0,0 +1,17 @@
|
||||
class ActionNotFound(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Dispatcher:
|
||||
def __init__(self, actions: list):
|
||||
self._actions = actions
|
||||
|
||||
def __call__(self, task):
|
||||
try:
|
||||
choosen_action = self._actions[task.action]
|
||||
except KeyError:
|
||||
raise ActionNotFound(
|
||||
f"The action {task.action} is not in {self._actions.keys()}"
|
||||
)
|
||||
|
||||
return choosen_action(args=task.args, deps=task.deps, output=task.output)
|
13
bopytex/worker/activate_corr.py
Normal file
13
bopytex/worker/activate_corr.py
Normal file
@ -0,0 +1,13 @@
|
||||
from bopytex.message import Message
|
||||
|
||||
|
||||
def activate_corr(args, deps, output):
|
||||
no_solution = args["latex"]["no_solution"]
|
||||
solution = args["latex"]["solution"]
|
||||
|
||||
with open(deps[0], "r") as input_f:
|
||||
with open(output, "w") as output_f:
|
||||
for line in input_f.readlines():
|
||||
output_f.write(line.replace(no_solution, solution))
|
||||
|
||||
return Message(0, [f"ACTIVATE CORR - {deps[0]} to {output}"], [])
|
2
bopytex/worker/clean.py
Normal file
2
bopytex/worker/clean.py
Normal file
@ -0,0 +1,2 @@
|
||||
def clean(args: dict, deps, output):
|
||||
pass
|
26
bopytex/worker/compile.py
Normal file
26
bopytex/worker/compile.py
Normal file
@ -0,0 +1,26 @@
|
||||
import subprocess
|
||||
|
||||
from bopytex.message import Message
|
||||
|
||||
from ..message import SubprocessMessage
|
||||
|
||||
|
||||
def curstomtex(command: str, options: str):
|
||||
def func(args: dict, deps, output) -> Message:
|
||||
compile_process = subprocess.Popen(
|
||||
[command, options, deps[0]],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
)
|
||||
return Message(
|
||||
compile_process.wait(),
|
||||
list(compile_process.stdout),
|
||||
list(compile_process.stderr),
|
||||
)
|
||||
|
||||
return func
|
||||
|
||||
|
||||
latexmk = curstomtex("latexmk", "-f")
|
||||
pdflatex = curstomtex("pdflatex", "--interaction=nonstopmode")
|
32
bopytex/worker/generate.py
Normal file
32
bopytex/worker/generate.py
Normal file
@ -0,0 +1,32 @@
|
||||
from jinja2.environment import Template
|
||||
|
||||
from bopytex.message import Message
|
||||
|
||||
|
||||
def generate(args, deps, output):
|
||||
env = args["options"]["jinja2"]["environment"]
|
||||
template = env.get_template(deps[0])
|
||||
|
||||
variables = {
|
||||
"options": args["options"],
|
||||
"subject": args["subject"],
|
||||
}
|
||||
|
||||
try:
|
||||
args["options"]["direct_access"]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
for (k, v) in args["options"]["direct_access"].items():
|
||||
if k not in ["options", "subject"]:
|
||||
variables[k] = v
|
||||
|
||||
try:
|
||||
with open(output, "w") as out:
|
||||
fed = template.render(variables)
|
||||
out.write(fed)
|
||||
|
||||
return Message(0, [f"GENERATE - {deps[0]} to {output}"], [])
|
||||
|
||||
except Exception as e:
|
||||
return Message(1, [], [e])
|
32
bopytex/worker/join_pdf.py
Normal file
32
bopytex/worker/join_pdf.py
Normal file
@ -0,0 +1,32 @@
|
||||
import subprocess
|
||||
|
||||
from bopytex.message import Message, SubprocessMessage
|
||||
|
||||
|
||||
def pdfjam(args: dict, deps, output):
|
||||
joining_process = subprocess.Popen(
|
||||
["pdfjam"] + deps + ["-o", output],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
)
|
||||
return Message(
|
||||
joining_process.wait(),
|
||||
list(joining_process.stdout),
|
||||
list(joining_process.stderr),
|
||||
)
|
||||
|
||||
|
||||
def gs(args: dict, deps, output):
|
||||
"""Not working. The command works in terminal but not here"""
|
||||
joining_process = subprocess.Popen(
|
||||
["gs", f"-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile={output}"] + deps,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
)
|
||||
return Message(
|
||||
joining_process.wait(),
|
||||
list(joining_process.stdout),
|
||||
list(joining_process.stderr),
|
||||
)
|
@ -198,5 +198,3 @@ SSH_TARGET_DIR=/var/docker/opytex.org/www/opytex
|
||||
|
||||
rsync_upload: html
|
||||
rsync -e "ssh" -P -rvzc --delete $(BUILDDIR)/html/ $(SSH_CONF):$(SSH_TARGET_DIR) --cvs-exclude
|
||||
|
||||
|
||||
|
@ -188,4 +188,3 @@ Calculer les longueurs $OC$ et $AB$.
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "master"
|
||||
%%% End:
|
||||
|
||||
|
@ -13,70 +13,70 @@
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
# 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
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.ifconfig',
|
||||
'sphinx.ext.viewcode',
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.mathjax",
|
||||
"sphinx.ext.ifconfig",
|
||||
"sphinx.ext.viewcode",
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = 'Opytex'
|
||||
copyright = '2016, Benjamin Bertrand'
|
||||
author = 'Benjamin Bertrand'
|
||||
project = "Opytex"
|
||||
copyright = "2016, Benjamin Bertrand"
|
||||
author = "Benjamin Bertrand"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.1'
|
||||
version = "0.1"
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.1'
|
||||
release = "0.1"
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# 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
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
@ -84,27 +84,27 @@ exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# 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.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
# keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
@ -114,159 +114,153 @@ todo_include_todos = False
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#html_theme = 'alabaster'
|
||||
# html_theme = 'alabaster'
|
||||
import sphinx_rtd_theme
|
||||
|
||||
html_theme = "sphinx_rtd_theme"
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# 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,
|
||||
# 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
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
# html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
# html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
# html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
# html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'Opytexdoc'
|
||||
htmlhelp_basename = "Opytexdoc"
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'Opytex.tex', 'Opytex Documentation',
|
||||
'Benjamin Bertrand', 'manual'),
|
||||
(master_doc, "Opytex.tex", "Opytex Documentation", "Benjamin Bertrand", "manual"),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'opytex', 'Opytex Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
man_pages = [(master_doc, "opytex", "Opytex Documentation", [author], 1)]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
@ -275,19 +269,25 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'Opytex', 'Opytex Documentation',
|
||||
author, 'Opytex', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"Opytex",
|
||||
"Opytex Documentation",
|
||||
author,
|
||||
"Opytex",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
# texinfo_no_detailmenu = False
|
||||
|
@ -38,4 +38,3 @@ Indices and tables
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
|
@ -158,6 +158,3 @@ Il est possible aussi de créer les sujets et les corrections en même temps ave
|
||||
.. code-block:: bash
|
||||
|
||||
opytex -t tpl_DM.tex -c -N 60
|
||||
|
||||
|
||||
|
||||
|
BIN
example/simple/joined_example.pdf
Normal file
BIN
example/simple/joined_example.pdf
Normal file
Binary file not shown.
44
example/simple/tpl_example.tex
Normal file
44
example/simple/tpl_example.tex
Normal file
@ -0,0 +1,44 @@
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\title{Bopytex example -- \Var{ subject.number }}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
%- set a = 10
|
||||
%- set n = 2
|
||||
We have two variables
|
||||
\begin{itemize}
|
||||
\item a: \Var{a}
|
||||
\item n: \Var{n}
|
||||
\end{itemize}
|
||||
|
||||
%# We can use blocks
|
||||
\begin{itemize}
|
||||
%- for i in range(n)
|
||||
\item \Var{a}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
|
||||
\section{Variables}
|
||||
\subsection{subject}
|
||||
\begin{itemize}
|
||||
%- for k,v in subject.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
\subsection{options}
|
||||
\begin{itemize}
|
||||
%- for k,v in options.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\end{document}
|
7
example/usecase/bopytex_config.py
Normal file
7
example/usecase/bopytex_config.py
Normal file
@ -0,0 +1,7 @@
|
||||
import random
|
||||
|
||||
from mapytex import Expression
|
||||
|
||||
random.seed(0)
|
||||
|
||||
direct_access = {"Expression": Expression, "random": random.random}
|
BIN
example/usecase/joined_example.pdf
Normal file
BIN
example/usecase/joined_example.pdf
Normal file
Binary file not shown.
6
example/usecase/students.csv
Normal file
6
example/usecase/students.csv
Normal file
@ -0,0 +1,6 @@
|
||||
"Name","Age","Email","fraction level","calculus level"
|
||||
"Spike Tucker","22","s.tucker@randatmail.com","7","3"
|
||||
"Martin Payne","21","m.payne@randatmail.com","7","3"
|
||||
"Kimberly Baker","20","k.baker@randatmail.com","1","8"
|
||||
"Emma Bailey","29","e.bailey@randatmail.com","2","5"
|
||||
"Nicholas Taylor","28","n.taylor@randatmail.com","3","3"
|
|
36
example/usecase/tpl_example.tex
Normal file
36
example/usecase/tpl_example.tex
Normal file
@ -0,0 +1,36 @@
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\title{Bopytex with Mapytex example -- \Var{ subject.number }}
|
||||
|
||||
% solution/print = false
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
%- set e = Expression.random("{a} + {b}")
|
||||
\Var{e}
|
||||
|
||||
\Var{e.simplify()}
|
||||
|
||||
\section{Variables}
|
||||
\subsection{subject}
|
||||
\begin{itemize}
|
||||
%- for k,v in subject.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
\subsection{options}
|
||||
\begin{itemize}
|
||||
%- for k,v in options.items()
|
||||
\item
|
||||
\begin{verbatim}
|
||||
\Var{k}: \Var{v}
|
||||
\end{verbatim}
|
||||
%- endfor
|
||||
\end{itemize}
|
||||
|
||||
\end{document}
|
@ -1,19 +0,0 @@
|
||||
% vim:ft=tex:
|
||||
%
|
||||
\documentclass[12pt]{article}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\section{Ajouts de fractions}
|
||||
|
||||
Adding two fractions
|
||||
%- set e = Expression.random("{a} / {b} + {c} / {k*b}", ["b > 1", "k>1"])
|
||||
\[
|
||||
A = \Var{e}
|
||||
\]
|
||||
Solution
|
||||
\[
|
||||
\Var{e.simplify().explain() | join('=')}
|
||||
\]
|
||||
|
||||
\end{document}
|
454
poetry.lock
generated
Normal file
454
poetry.lock
generated
Normal file
@ -0,0 +1,454 @@
|
||||
[[package]]
|
||||
name = "atomicwrites"
|
||||
version = "1.4.1"
|
||||
description = "Atomic file writes."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
|
||||
[[package]]
|
||||
name = "attrs"
|
||||
version = "21.4.0"
|
||||
description = "Classes Without Boilerplate"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.extras]
|
||||
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
|
||||
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
|
||||
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
|
||||
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
|
||||
|
||||
[[package]]
|
||||
name = "cfgv"
|
||||
version = "3.3.1"
|
||||
description = "Validate configuration and produce human readable error messages."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6.1"
|
||||
|
||||
[[package]]
|
||||
name = "click"
|
||||
version = "8.1.3"
|
||||
description = "Composable command line interface toolkit"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.5"
|
||||
description = "Cross-platform colored terminal text."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "distlib"
|
||||
version = "0.3.5"
|
||||
description = "Distribution utilities"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "filelock"
|
||||
version = "3.7.1"
|
||||
description = "A platform independent file lock."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2021.8.17b43)", "sphinx (>=4.1)", "sphinx-autodoc-typehints (>=1.12)"]
|
||||
testing = ["covdefaults (>=1.2.0)", "coverage (>=4)", "pytest (>=4)", "pytest-cov", "pytest-timeout (>=1.4.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "identify"
|
||||
version = "2.5.2"
|
||||
description = "File identification library for Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.extras]
|
||||
license = ["ukkonen"]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "1.1.1"
|
||||
description = "iniconfig: brain-dead simple config-ini parsing"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "jinja2"
|
||||
version = "3.1.2"
|
||||
description = "A very fast and expressive template engine."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
MarkupSafe = ">=2.0"
|
||||
|
||||
[package.extras]
|
||||
i18n = ["Babel (>=2.7)"]
|
||||
|
||||
[[package]]
|
||||
name = "markupsafe"
|
||||
version = "2.1.1"
|
||||
description = "Safely add untrusted strings to HTML/XML markup."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "nodeenv"
|
||||
version = "1.7.0"
|
||||
description = "Node.js virtual environment builder"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*"
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "21.3"
|
||||
description = "Core utilities for Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "2.5.2"
|
||||
description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"]
|
||||
test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"]
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.0.0"
|
||||
description = "plugin and hook calling mechanisms for python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
testing = ["pytest-benchmark", "pytest"]
|
||||
dev = ["tox", "pre-commit"]
|
||||
|
||||
[[package]]
|
||||
name = "pre-commit"
|
||||
version = "2.20.0"
|
||||
description = "A framework for managing and maintaining multi-language pre-commit hooks."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
cfgv = ">=2.0.0"
|
||||
identify = ">=1.0.0"
|
||||
nodeenv = ">=0.11.1"
|
||||
pyyaml = ">=5.1"
|
||||
toml = "*"
|
||||
virtualenv = ">=20.0.8"
|
||||
|
||||
[[package]]
|
||||
name = "py"
|
||||
version = "1.11.0"
|
||||
description = "library with cross-python path, ini-parsing, io, code, log facilities"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[[package]]
|
||||
name = "pyparsing"
|
||||
version = "3.0.9"
|
||||
description = "pyparsing module - Classes and methods to define and execute parsing grammars"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6.8"
|
||||
|
||||
[package.extras]
|
||||
diagrams = ["railroad-diagrams", "jinja2"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "7.1.2"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
|
||||
attrs = ">=19.2.0"
|
||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
iniconfig = "*"
|
||||
packaging = "*"
|
||||
pluggy = ">=0.12,<2.0"
|
||||
py = ">=1.8.2"
|
||||
tomli = ">=1.0.0"
|
||||
|
||||
[package.extras]
|
||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml"
|
||||
version = "6.0"
|
||||
description = "YAML parser and emitter for Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "six"
|
||||
version = "1.16.0"
|
||||
description = "Python 2 and 3 compatibility utilities"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.10.2"
|
||||
description = "Python Library for Tom's Obvious, Minimal Language"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "2.0.1"
|
||||
description = "A lil' TOML parser"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "tox"
|
||||
version = "3.25.1"
|
||||
description = "tox is a generic virtualenv management and test command line tool"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = ">=0.4.1", markers = "platform_system == \"Windows\""}
|
||||
filelock = ">=3.0.0"
|
||||
packaging = ">=14"
|
||||
pluggy = ">=0.12.0"
|
||||
py = ">=1.4.17"
|
||||
six = ">=1.14.0"
|
||||
toml = ">=0.9.4"
|
||||
virtualenv = ">=16.0.0,<20.0.0 || >20.0.0,<20.0.1 || >20.0.1,<20.0.2 || >20.0.2,<20.0.3 || >20.0.3,<20.0.4 || >20.0.4,<20.0.5 || >20.0.5,<20.0.6 || >20.0.6,<20.0.7 || >20.0.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["pygments-github-lexers (>=0.0.5)", "sphinx (>=2.0.0)", "sphinxcontrib-autoprogram (>=0.1.5)", "towncrier (>=18.5.0)"]
|
||||
testing = ["flaky (>=3.4.0)", "freezegun (>=0.3.11)", "pytest (>=4.0.0)", "pytest-cov (>=2.5.1)", "pytest-mock (>=1.10.0)", "pytest-randomly (>=1.0.0)", "psutil (>=5.6.1)", "pathlib2 (>=2.3.3)"]
|
||||
|
||||
[[package]]
|
||||
name = "virtualenv"
|
||||
version = "20.16.2"
|
||||
description = "Virtual Python Environment builder"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
distlib = ">=0.3.1,<1"
|
||||
filelock = ">=3.2,<4"
|
||||
platformdirs = ">=2,<3"
|
||||
|
||||
[package.extras]
|
||||
docs = ["proselint (>=0.10.2)", "sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=21.3)"]
|
||||
testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", "packaging (>=20.0)", "pytest (>=4)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.1)", "pytest-mock (>=2)", "pytest-randomly (>=1)", "pytest-timeout (>=1)"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "2e8e9679154491f8e2d8611aa619ec3b2be4be7b48b6a654230459b076b51886"
|
||||
|
||||
[metadata.files]
|
||||
atomicwrites = [
|
||||
{file = "atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"},
|
||||
]
|
||||
attrs = [
|
||||
{file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"},
|
||||
{file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"},
|
||||
]
|
||||
cfgv = [
|
||||
{file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"},
|
||||
{file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"},
|
||||
]
|
||||
click = [
|
||||
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
|
||||
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
|
||||
]
|
||||
colorama = [
|
||||
{file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
|
||||
{file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
|
||||
]
|
||||
distlib = [
|
||||
{file = "distlib-0.3.5-py2.py3-none-any.whl", hash = "sha256:b710088c59f06338ca514800ad795a132da19fda270e3ce4affc74abf955a26c"},
|
||||
{file = "distlib-0.3.5.tar.gz", hash = "sha256:a7f75737c70be3b25e2bee06288cec4e4c221de18455b2dd037fe2a795cab2fe"},
|
||||
]
|
||||
filelock = [
|
||||
{file = "filelock-3.7.1-py3-none-any.whl", hash = "sha256:37def7b658813cda163b56fc564cdc75e86d338246458c4c28ae84cabefa2404"},
|
||||
{file = "filelock-3.7.1.tar.gz", hash = "sha256:3a0fd85166ad9dbab54c9aec96737b744106dc5f15c0b09a6744a445299fcf04"},
|
||||
]
|
||||
identify = [
|
||||
{file = "identify-2.5.2-py2.py3-none-any.whl", hash = "sha256:feaa9db2dc0ce333b453ce171c0cf1247bbfde2c55fc6bb785022d411a1b78b5"},
|
||||
{file = "identify-2.5.2.tar.gz", hash = "sha256:a3d4c096b384d50d5e6dc5bc8b9bc44f1f61cefebd750a7b3e9f939b53fb214d"},
|
||||
]
|
||||
iniconfig = [
|
||||
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
|
||||
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
|
||||
]
|
||||
jinja2 = [
|
||||
{file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"},
|
||||
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
|
||||
]
|
||||
markupsafe = [
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-win32.whl", hash = "sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6"},
|
||||
{file = "MarkupSafe-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-win32.whl", hash = "sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff"},
|
||||
{file = "MarkupSafe-2.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-win32.whl", hash = "sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1"},
|
||||
{file = "MarkupSafe-2.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-win32.whl", hash = "sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c"},
|
||||
{file = "MarkupSafe-2.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247"},
|
||||
{file = "MarkupSafe-2.1.1.tar.gz", hash = "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"},
|
||||
]
|
||||
nodeenv = [
|
||||
{file = "nodeenv-1.7.0-py2.py3-none-any.whl", hash = "sha256:27083a7b96a25f2f5e1d8cb4b6317ee8aeda3bdd121394e5ac54e498028a042e"},
|
||||
{file = "nodeenv-1.7.0.tar.gz", hash = "sha256:e0e7f7dfb85fc5394c6fe1e8fa98131a2473e04311a45afb6508f7cf1836fa2b"},
|
||||
]
|
||||
packaging = [
|
||||
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
|
||||
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
|
||||
]
|
||||
platformdirs = [
|
||||
{file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
|
||||
{file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"},
|
||||
]
|
||||
pluggy = [
|
||||
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
|
||||
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
|
||||
]
|
||||
pre-commit = [
|
||||
{file = "pre_commit-2.20.0-py2.py3-none-any.whl", hash = "sha256:51a5ba7c480ae8072ecdb6933df22d2f812dc897d5fe848778116129a681aac7"},
|
||||
{file = "pre_commit-2.20.0.tar.gz", hash = "sha256:a978dac7bc9ec0bcee55c18a277d553b0f419d259dadb4b9418ff2d00eb43959"},
|
||||
]
|
||||
py = [
|
||||
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
|
||||
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
||||
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
|
||||
]
|
||||
pytest = [
|
||||
{file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
|
||||
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
|
||||
]
|
||||
pyyaml = [
|
||||
{file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"},
|
||||
{file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"},
|
||||
]
|
||||
six = [
|
||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||
]
|
||||
toml = [
|
||||
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
|
||||
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
|
||||
]
|
||||
tomli = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
tox = [
|
||||
{file = "tox-3.25.1-py2.py3-none-any.whl", hash = "sha256:c38e15f4733683a9cc0129fba078633e07eb0961f550a010ada879e95fb32632"},
|
||||
{file = "tox-3.25.1.tar.gz", hash = "sha256:c138327815f53bc6da4fe56baec5f25f00622ae69ef3fe4e1e385720e22486f9"},
|
||||
]
|
||||
virtualenv = [
|
||||
{file = "virtualenv-20.16.2-py2.py3-none-any.whl", hash = "sha256:635b272a8e2f77cb051946f46c60a54ace3cb5e25568228bd6b57fc70eca9ff3"},
|
||||
{file = "virtualenv-20.16.2.tar.gz", hash = "sha256:0ef5be6d07181946891f5abc8047fda8bc2f0b4b9bf222c64e6e8963baee76db"},
|
||||
]
|
21
pyproject.toml
Normal file
21
pyproject.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[tool.poetry]
|
||||
name = "bopytex"
|
||||
version = "1.0.0rc1"
|
||||
description = "Command line tool for compiling latex with python command embedded"
|
||||
authors = ["Bertrand Benjamin <benjamin.bertrand@opytex.org>"]
|
||||
license = "GPLv3"
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
click = "^8.1.3"
|
||||
Jinja2 = "^3.1.2"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pre-commit = "^2.20.0"
|
||||
tox = "^3.25.1"
|
||||
pytest = "^7.1.2"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
@ -1,33 +0,0 @@
|
||||
alabaster==0.7.10
|
||||
appdirs==1.4.3
|
||||
Babel==2.4.0
|
||||
decorator==4.0.11
|
||||
docutils==0.13.1
|
||||
imagesize==0.7.1
|
||||
ipython==5.3.0
|
||||
ipython-genutils==0.2.0
|
||||
Jinja2==2.9.6
|
||||
location==0.0.7
|
||||
MarkupSafe==1.0
|
||||
mpmath==0.19
|
||||
packaging==16.8
|
||||
pexpect==4.2.1
|
||||
pickleshare==0.7.4
|
||||
prompt-toolkit==1.0.14
|
||||
ptyprocess==0.5.1
|
||||
Pygments==2.2.0
|
||||
pyparsing==2.2.0
|
||||
## !! Could not determine repository location
|
||||
pytz==2017.2
|
||||
requests==2.13.0
|
||||
simplegeneric==0.8.1
|
||||
six==1.10.0
|
||||
snowballstemmer==1.2.1
|
||||
Sphinx==1.5.5
|
||||
sphinx-rtd-theme==0.2.4
|
||||
sympy==1.0
|
||||
traitlets==4.3.2
|
||||
wcwidth==0.1.7
|
||||
mapytex==2.0.8
|
||||
mypytex==0.2
|
||||
path.py==12.1
|
25
setup.py
25
setup.py
@ -4,21 +4,18 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='Bopytex',
|
||||
version='0.2',
|
||||
description='Command line tool for compiling latex with python command embedded',
|
||||
author='Benjamin Bertrand',
|
||||
author_email='programming@opytex.org',
|
||||
packages=['bopytex'],
|
||||
name="Bopytex",
|
||||
version="0.9",
|
||||
description="Command line tool for compiling latex with python command embedded",
|
||||
author="Benjamin Bertrand",
|
||||
author_email="benjamin.bertrand@opytex.org",
|
||||
packages=["bopytex"],
|
||||
install_requires=[
|
||||
'mapytex',
|
||||
'mypytex',
|
||||
'click',
|
||||
],
|
||||
entry_points={
|
||||
"console_scripts": ['bopytex=bopytex.script:new']
|
||||
},
|
||||
)
|
||||
"click",
|
||||
"jinja2",
|
||||
],
|
||||
entry_points={"console_scripts": ["bopytex=bopytex.script:new"]},
|
||||
)
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
|
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
0
test/fakes/__init__.py
Normal file
0
test/fakes/__init__.py
Normal file
11
test/fakes/dispatcher.py
Normal file
11
test/fakes/dispatcher.py
Normal file
@ -0,0 +1,11 @@
|
||||
from bopytex.worker import Dispatcher
|
||||
|
||||
from .workers import fail_worker, fake_worker, success_worker
|
||||
|
||||
fake_dispatcher = Dispatcher(
|
||||
{
|
||||
"FAKE": fake_worker,
|
||||
"SUCCESS": success_worker,
|
||||
"FAILURE": fail_worker,
|
||||
}
|
||||
)
|
9
test/fakes/planner.py
Normal file
9
test/fakes/planner.py
Normal file
@ -0,0 +1,9 @@
|
||||
from bopytex.tasks import Task
|
||||
|
||||
|
||||
def simple(options: dict) -> list[Task]:
|
||||
"""Simple planner with options['quantity'] tasks and no dependencies"""
|
||||
return [
|
||||
Task("FAKE", args={"number": i}, deps=[], output=f"{i}")
|
||||
for i in range(options["quantity"])
|
||||
]
|
13
test/fakes/workers.py
Normal file
13
test/fakes/workers.py
Normal file
@ -0,0 +1,13 @@
|
||||
from bopytex.message import Message
|
||||
|
||||
|
||||
def fake_worker(args, deps, output):
|
||||
return Message(0, [f"FAKE - {args} - {deps} - {output}"], [])
|
||||
|
||||
|
||||
def success_worker(args, deps, output):
|
||||
return Message(0, [f"SUCCESS - {args} - {deps} - {output}"], [])
|
||||
|
||||
|
||||
def fail_worker(args, deps, output):
|
||||
return Message(1, [f"FAILURE - {args} - {deps} - {output}"], [])
|
@ -1,6 +0,0 @@
|
||||
nom,classe,elo
|
||||
Bob,1ST,1000
|
||||
Pipo,1ST,1300
|
||||
Popi,1ST,100
|
||||
Boule,1ST,4000
|
||||
Bill,1ST,1300
|
|
@ -1,22 +0,0 @@
|
||||
\documentclass[12pt]{article}
|
||||
\usepackage[utf8x]{inputenc}
|
||||
\usepackage[francais]{babel}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsfonts}
|
||||
|
||||
|
||||
\title{
|
||||
Tests
|
||||
}
|
||||
\author{
|
||||
Benjamin Bertrand
|
||||
}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
|
||||
|
||||
\end{document}
|
@ -1,212 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
import pytest
|
||||
import os
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
from bopytex.bopytex import produce_and_compile, subject_metadatas
|
||||
|
||||
SNIPPETS_PATH = Path("snippets/")
|
||||
TEST_PATH = Path("test")
|
||||
TEST_TEMPLATE_PATH = TEST_PATH / "templates/"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def prepare_test_template(tmp_path):
|
||||
""" Create a tmp directory, copy snippets inside
|
||||
|
||||
return tmp directory name
|
||||
"""
|
||||
tmp = tmp_path
|
||||
snippets = TEST_TEMPLATE_PATH.glob("tpl_*.tex")
|
||||
for s in snippets:
|
||||
copyfile(s, tmp / s.name)
|
||||
csvs = TEST_PATH.glob("*.csv")
|
||||
for s in csvs:
|
||||
copyfile(s, tmp / s.name)
|
||||
|
||||
prev_dir = Path.cwd()
|
||||
os.chdir(tmp)
|
||||
yield tmp
|
||||
os.chdir(prev_dir)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def prepare_snippets(tmp_path):
|
||||
""" Create a tmp directory, copy snippets inside
|
||||
|
||||
return tmp directory name
|
||||
"""
|
||||
tmp = tmp_path
|
||||
snippets = SNIPPETS_PATH.glob("tpl_*.tex")
|
||||
for s in snippets:
|
||||
copyfile(s, tmp / s.name)
|
||||
|
||||
prev_dir = Path.cwd()
|
||||
os.chdir(tmp)
|
||||
yield tmp
|
||||
os.chdir(prev_dir)
|
||||
|
||||
|
||||
def test_produce_and_compile_base(prepare_test_template):
|
||||
test_tpl = list(Path(".").glob("tpl_*.tex"))
|
||||
assert [tpl.name for tpl in test_tpl] == ["tpl_test.tex"]
|
||||
for tpl in test_tpl:
|
||||
produce_and_compile(
|
||||
{
|
||||
"template": tpl,
|
||||
"working_dir": None,
|
||||
"only_corr": False,
|
||||
"students_csv": None,
|
||||
"number_subjects": 1,
|
||||
"dirty": False,
|
||||
"no_compile": False,
|
||||
"no_join": False,
|
||||
"corr": False,
|
||||
"crazy": False,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_produce_and_compile_csv(prepare_test_template):
|
||||
test_tpl = Path(".").glob("tpl_*.tex")
|
||||
for tpl in test_tpl:
|
||||
options = {
|
||||
"template": tpl,
|
||||
"working_dir": None,
|
||||
"only_corr": False,
|
||||
"students_csv": "students.csv",
|
||||
"number_subjects": 1,
|
||||
"dirty": False,
|
||||
"no_compile": False,
|
||||
"no_join": False,
|
||||
"corr": False,
|
||||
"crazy": False,
|
||||
}
|
||||
# produce_and_compile(options)
|
||||
|
||||
|
||||
def test_metadatas(prepare_test_template):
|
||||
test_tpl = Path(".").glob("tpl_*.tex")
|
||||
for tpl in test_tpl:
|
||||
options = {
|
||||
"template": tpl,
|
||||
"working_dir": None,
|
||||
"only_corr": False,
|
||||
"students_csv": "students.csv",
|
||||
"number_subjects": 1,
|
||||
"dirty": False,
|
||||
"no_compile": False,
|
||||
"no_join": False,
|
||||
"corr": False,
|
||||
"crazy": False,
|
||||
}
|
||||
metadatas = subject_metadatas(options)
|
||||
meta = [
|
||||
{
|
||||
"num": "01",
|
||||
"nom": "Bob",
|
||||
"classe": "1ST",
|
||||
"elo": "1000",
|
||||
"texfile": "01_test.tex",
|
||||
"template": "tpl_test.tex",
|
||||
"directory": ".",
|
||||
},
|
||||
{
|
||||
"num": "02",
|
||||
"nom": "Pipo",
|
||||
"classe": "1ST",
|
||||
"elo": "1300",
|
||||
"texfile": "02_test.tex",
|
||||
"template": "tpl_test.tex",
|
||||
"directory": ".",
|
||||
},
|
||||
{
|
||||
"num": "03",
|
||||
"nom": "Popi",
|
||||
"classe": "1ST",
|
||||
"elo": "100",
|
||||
"texfile": "03_test.tex",
|
||||
"template": "tpl_test.tex",
|
||||
"directory": ".",
|
||||
},
|
||||
{
|
||||
"num": "04",
|
||||
"nom": "Boule",
|
||||
"classe": "1ST",
|
||||
"elo": "4000",
|
||||
"texfile": "04_test.tex",
|
||||
"template": "tpl_test.tex",
|
||||
"directory": ".",
|
||||
},
|
||||
{
|
||||
"num": "05",
|
||||
"nom": "Bill",
|
||||
"classe": "1ST",
|
||||
"elo": "1300",
|
||||
"texfile": "05_test.tex",
|
||||
"template": "tpl_test.tex",
|
||||
"directory": ".",
|
||||
},
|
||||
]
|
||||
assert metadatas == meta
|
||||
|
||||
|
||||
def test_pdfjoin_current_directory(prepare_test_template):
|
||||
wdir = prepare_test_template
|
||||
pass
|
||||
|
||||
|
||||
def test_pdfjoin_deep_directory():
|
||||
pass
|
||||
|
||||
|
||||
def test_pdfjoin_dont_remove():
|
||||
pass
|
||||
|
||||
|
||||
def test_subject_names():
|
||||
pass
|
||||
|
||||
|
||||
def test_feed_texfiles():
|
||||
pass
|
||||
|
||||
|
||||
def test_tex2pdf_current_directory():
|
||||
pass
|
||||
|
||||
|
||||
def test_tex2pdf_deep_directory():
|
||||
pass
|
||||
|
||||
|
||||
def test_activate_solution():
|
||||
pass
|
||||
|
||||
|
||||
# def test_snippets(prepare_snippets):
|
||||
# snippets = list(Path(".").glob("tpl_*.tex"))
|
||||
# for tpl in snippets:
|
||||
# produce_and_compile(
|
||||
# {
|
||||
# "template": tpl,
|
||||
# "working_dir": None,
|
||||
# "only_corr": False,
|
||||
# "students_csv": None,
|
||||
# "number_subjects": 1,
|
||||
# "dirty": False,
|
||||
# "no_compile": False,
|
||||
# "no_join": False,
|
||||
# "corr": False,
|
||||
# "crazy": False,
|
||||
# }
|
||||
# )
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
88
test/test_e2e.py
Normal file
88
test/test_e2e.py
Normal file
@ -0,0 +1,88 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
import pytest
|
||||
|
||||
from bopytex.service import main
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def template_path(tmp_path):
|
||||
template = tmp_path / "tpl_source.tex"
|
||||
with open(template, "w") as tpl:
|
||||
tpl.write(
|
||||
"""
|
||||
\\documentclass{article}
|
||||
|
||||
\\begin{document}
|
||||
First document.
|
||||
|
||||
Subject {{ number }}
|
||||
\\end{document}
|
||||
"""
|
||||
)
|
||||
return template
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bad_template_path(tmp_path):
|
||||
template = tmp_path / "tpl_source.tex"
|
||||
with open(template, "w") as tpl:
|
||||
tpl.write(
|
||||
"""
|
||||
\\documentclass{article}
|
||||
|
||||
\\begin{document}
|
||||
First document.
|
||||
|
||||
Subject {{ number }}
|
||||
"""
|
||||
)
|
||||
return template
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jinja2_env(tmp_path):
|
||||
templateEnv = jinja2.Environment(loader=jinja2.FileSystemLoader(tmp_path))
|
||||
return templateEnv
|
||||
|
||||
|
||||
def test_with_default_planner(template_path, jinja2_env, tmp_path):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
options = {
|
||||
"template": str(template_path.name),
|
||||
"quantity_subjects": 3,
|
||||
"corr": False,
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"jinja2": {
|
||||
"environment": jinja2_env,
|
||||
},
|
||||
}
|
||||
|
||||
for message in main(**options):
|
||||
assert message.status == 0
|
||||
|
||||
assert Path("joined_source.pdf").exists()
|
||||
|
||||
|
||||
def test_with_default_planner_bad_template(bad_template_path, jinja2_env, tmp_path):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
options = {
|
||||
"template": str(bad_template_path.name),
|
||||
"quantity_subjects": 3,
|
||||
"corr": False,
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"jinja2": {
|
||||
"environment": jinja2_env,
|
||||
},
|
||||
}
|
||||
|
||||
for message in main(**options):
|
||||
pass
|
||||
|
||||
assert not Path("joined_source.pdf").exists()
|
386
test/test_planner.py
Normal file
386
test/test_planner.py
Normal file
@ -0,0 +1,386 @@
|
||||
from bopytex.planner.activate_corr_compile_join_planner import (
|
||||
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
|
||||
|
||||
|
||||
def test_tasks_builder_generate():
|
||||
tasks = gcj_task_builder(
|
||||
options={
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"no_pdf": True,
|
||||
}
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"no_pdf": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"no_pdf": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_tasks_builder_generate_compile():
|
||||
tasks = gcj_task_builder(
|
||||
options={
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"no_join": True,
|
||||
}
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"no_join": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["01_source.tex"],
|
||||
output="01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"no_join": True,
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["02_source.tex"],
|
||||
output="02_source.pdf",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_tasks_builder_generate_compile_join():
|
||||
tasks = gcj_task_builder(
|
||||
options={
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
}
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["01_source.tex"],
|
||||
output="01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["02_source.tex"],
|
||||
output="02_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=["01_source.pdf", "02_source.pdf"],
|
||||
output="joined_source.pdf",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_tasks_builder_generate_compile_corr():
|
||||
tasks = gcj_task_builder(
|
||||
options={
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
}
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["01_source.tex"],
|
||||
output="01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
"no_pdf": False,
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
},
|
||||
deps=["01_source.tex"],
|
||||
output="corr_01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_01_source.tex"],
|
||||
output="corr_01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["02_source.tex"],
|
||||
output="02_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
"corr": True,
|
||||
"no_join": True,
|
||||
"no_pdf": False,
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
},
|
||||
deps=["02_source.tex"],
|
||||
output="corr_02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_02_source.tex"],
|
||||
output="corr_02_source.pdf",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_tasks_builder_generate_compile_corr_joined():
|
||||
tasks = gcj_task_builder(
|
||||
options={
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
}
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "01"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["01_source.tex"],
|
||||
output="01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
},
|
||||
deps=["01_source.tex"],
|
||||
output="corr_01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_01_source.tex"],
|
||||
output="corr_01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="GENERATE",
|
||||
args={
|
||||
"options": {
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
"template": "tpl_source.tex",
|
||||
},
|
||||
"subject": {"number": "02"},
|
||||
},
|
||||
deps=["tpl_source.tex"],
|
||||
output="02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["02_source.tex"],
|
||||
output="02_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
"corr": True,
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"template": "tpl_source.tex",
|
||||
"subjects": [{"number": "01"}, {"number": "02"}],
|
||||
},
|
||||
deps=["02_source.tex"],
|
||||
output="corr_02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_02_source.tex"],
|
||||
output="corr_02_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=["01_source.pdf", "02_source.pdf"],
|
||||
output="joined_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
||||
output="corr_joined_source.pdf",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def test_only_corr_tasks_builder():
|
||||
tasks = accj_task_builder(
|
||||
options={
|
||||
"sources": ["01_source.tex", "02_source.tex"],
|
||||
}
|
||||
)
|
||||
assert tasks == [
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"sources": ["01_source.tex", "02_source.tex"],
|
||||
},
|
||||
deps=["01_source.tex"],
|
||||
output="corr_01_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_01_source.tex"],
|
||||
output="corr_01_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="ACTIVATE_CORR",
|
||||
args={
|
||||
"no_join": False,
|
||||
"no_pdf": False,
|
||||
"sources": ["01_source.tex", "02_source.tex"],
|
||||
},
|
||||
deps=["02_source.tex"],
|
||||
output="corr_02_source.tex",
|
||||
),
|
||||
Task(
|
||||
action="COMPILE",
|
||||
args={},
|
||||
deps=["corr_02_source.tex"],
|
||||
output="corr_02_source.pdf",
|
||||
),
|
||||
Task(
|
||||
action="JOIN",
|
||||
args={},
|
||||
deps=["corr_01_source.pdf", "corr_02_source.pdf"],
|
||||
output="corr_joined.pdf",
|
||||
),
|
||||
]
|
163
test/test_scheduler.py
Normal file
163
test/test_scheduler.py
Normal file
@ -0,0 +1,163 @@
|
||||
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():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
tasks = [
|
||||
Task(action="FAKE", args={}, deps=["dep1", "dep2"], output="end1"),
|
||||
Task(action="FAKE", args={}, deps=["dep1", "dep3"], output="end2"),
|
||||
]
|
||||
scheduler.append(tasks)
|
||||
assert scheduler.tasks == tasks
|
||||
assert scheduler.all_deps == {"dep1", "dep2", "dep3"}
|
||||
assert scheduler.all_output == {"end1", "end2"}
|
||||
|
||||
|
||||
def test_schedule_one_task():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
tasks = [Task(action="FAKE", args={}, deps=[], output="end")]
|
||||
scheduler.append(tasks)
|
||||
|
||||
assert scheduler.doable_tasks == tasks
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert result.out == ["FAKE - {} - [] - end"]
|
||||
assert result.err == []
|
||||
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.output_done == ["end"]
|
||||
|
||||
|
||||
def test_schedule_one_task_with_args():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
tasks = [Task(action="FAKE", args={"task": "one"}, deps=[], output="one")]
|
||||
scheduler.append(tasks)
|
||||
|
||||
result = scheduler.next_task()
|
||||
|
||||
assert result.status == 0
|
||||
assert result.out == ["FAKE - {'task': 'one'} - [] - one"]
|
||||
assert result.err == []
|
||||
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.output_done == ["one"]
|
||||
|
||||
|
||||
def test_schedule_multiple_tasks():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
t1 = Task(action="FAKE", args={"task": "one"}, deps=[], output="one")
|
||||
t2 = Task(action="FAKE", args={"task": "two"}, deps=[], output="two")
|
||||
t3 = Task(action="FAKE", args={"task": "three"}, deps=[], output="three")
|
||||
scheduler.append([t1, t2, t3])
|
||||
|
||||
assert scheduler.doable_tasks == [t1, t2, t3]
|
||||
assert scheduler.is_finishable()
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert scheduler.tasks == [t2, t3]
|
||||
assert scheduler.output_done == ["one"]
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert scheduler.tasks == [t3]
|
||||
assert scheduler.output_done == ["one", "two"]
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.output_done == ["one", "two", "three"]
|
||||
|
||||
|
||||
def test_schedule_multiple_tasks_with_dependencies():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
t1 = Task(action="FAKE", args={"task": "one"}, deps=["three"], output="one")
|
||||
t2 = Task(action="FAKE", args={"task": "two"}, deps=["one"], output="two")
|
||||
t3 = Task(action="FAKE", args={"task": "three"}, deps=[], output="three")
|
||||
scheduler.append([t1, t2, t3])
|
||||
|
||||
assert scheduler.doable_tasks == [t3]
|
||||
assert scheduler.is_finishable()
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert scheduler.tasks == [t1, t2]
|
||||
assert scheduler.output_done == ["three"]
|
||||
assert scheduler.doable_tasks == [t1]
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert scheduler.tasks == [t2]
|
||||
assert scheduler.output_done == ["three", "one"]
|
||||
assert scheduler.doable_tasks == [t2]
|
||||
|
||||
result = scheduler.next_task()
|
||||
assert result.status == 0
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.output_done == ["three", "one", "two"]
|
||||
|
||||
|
||||
def test_schedule_multiple_tasks_with_dependencies_loop():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
t1 = Task(action="FAKE", args={"task": "one"}, deps=["three"], output="one")
|
||||
t2 = Task(action="FAKE", args={"task": "two"}, deps=["one"], output="two")
|
||||
t3 = Task(action="FAKE", args={"task": "three"}, deps=[], output="three")
|
||||
scheduler.append([t1, t2, t3])
|
||||
|
||||
for task in scheduler.backlog():
|
||||
pass
|
||||
|
||||
assert scheduler.output_done == ["three", "one", "two"]
|
||||
|
||||
|
||||
def test_schedule_empty_task():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
scheduler.append([])
|
||||
with pytest.raises(StopIteration):
|
||||
scheduler.next_task()
|
||||
|
||||
|
||||
def test_schedule_multiple_tasks_with_undoable_dependencies():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
t1 = Task(action="FAKE", args={"task": "one"}, deps=["three"], output="one")
|
||||
t2 = Task(action="FAKE", args={"task": "two"}, deps=[], output="two")
|
||||
scheduler.append([t1, t2])
|
||||
|
||||
assert scheduler.doable_tasks == [t2]
|
||||
assert not scheduler.is_finishable()
|
||||
|
||||
for _ in scheduler.backlog():
|
||||
pass
|
||||
|
||||
assert scheduler.tasks == [t1]
|
||||
assert scheduler.output_done == ["two"]
|
||||
assert scheduler.doable_tasks == []
|
||||
|
||||
|
||||
def test_schedule_multiple_tasks_with_failling_tasks():
|
||||
scheduler = Scheduler(dispatcher=fake_dispatcher)
|
||||
t1 = Task(action="FAILURE", args={"task": "one"}, deps=["three"], output="one")
|
||||
t2 = Task(action="FAKE", args={"task": "two"}, deps=["one"], output="two")
|
||||
t3 = Task(action="FAKE", args={"task": "three"}, deps=[], output="three")
|
||||
t4 = Task(action="FAILURE", args={"task": "four"}, deps=[], output="four")
|
||||
scheduler.append([t1, t2, t3, t4])
|
||||
|
||||
assert scheduler.doable_tasks == [t3, t4]
|
||||
assert scheduler.is_finishable()
|
||||
|
||||
status = []
|
||||
for message in scheduler.backlog():
|
||||
status.append(message.status)
|
||||
|
||||
assert status == [0, 1, 1]
|
||||
assert scheduler.tasks == [t2]
|
||||
assert scheduler.failed_tasks == [t1, t4]
|
||||
assert scheduler.output_done == ["three"]
|
||||
assert scheduler.doable_tasks == []
|
62
test/test_service.py
Normal file
62
test/test_service.py
Normal file
@ -0,0 +1,62 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from bopytex.planner import fake_planner
|
||||
from bopytex.service import build_config, orcherstrator
|
||||
from bopytex.tasks import Task
|
||||
from bopytex.worker import Dispatcher
|
||||
|
||||
from .fakes.workers import fake_worker
|
||||
|
||||
|
||||
def test_service():
|
||||
options = {"quantity": 3, "template": "tpl_src.tex"}
|
||||
dispatcher = Dispatcher(actions={"DO": fake_worker})
|
||||
|
||||
service = orcherstrator(options, fake_planner.simple, dispatcher)
|
||||
|
||||
for i, message in enumerate(service):
|
||||
assert message.status == 0
|
||||
assert message.out == [f"FAKE - {{'number': {i}}} - [] - {i}"]
|
||||
|
||||
|
||||
def test_get_config_no_configfile():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config_file(tmp_path):
|
||||
config_file = tmp_path / "bopytex_config.py"
|
||||
with open(config_file, "w") as f:
|
||||
f.write(
|
||||
"""
|
||||
from bopytex.jinja2_env.texenv import texenv
|
||||
jinja2 = {
|
||||
"environment": texenv,
|
||||
}
|
||||
"""
|
||||
)
|
||||
return config_file
|
||||
|
||||
|
||||
def test_get_config_with_configfile(config_file, tmp_path):
|
||||
os.chdir(tmp_path)
|
||||
config = build_config({"from_option": "config", "configfile": str(config_file)})
|
||||
assert type(config) == dict
|
||||
assert set(config.keys()) == {
|
||||
"generate",
|
||||
"configfile",
|
||||
"Dispatcher",
|
||||
"planner",
|
||||
"pdflatex",
|
||||
"clean",
|
||||
"latex",
|
||||
"activate_corr",
|
||||
"dispatcher",
|
||||
"pdfjam",
|
||||
"jinja2",
|
||||
"texenv",
|
||||
"from_option",
|
||||
}
|
||||
assert list(config["jinja2"].keys()) == ["environment"]
|
41
test/test_tasks.py
Normal file
41
test/test_tasks.py
Normal file
@ -0,0 +1,41 @@
|
||||
from bopytex.tasks import activate_corr_on, clean, compile_pdf, generate, join_pdfs
|
||||
|
||||
|
||||
def test_build_task_generate():
|
||||
template = "tpl_source.tex"
|
||||
task = generate(template, {"subject": "01"}, output="source.tex")
|
||||
assert task.action == "GENERATE"
|
||||
assert task.args == {"subject": "01"}
|
||||
assert task.deps == [template]
|
||||
|
||||
|
||||
def test_build_task_activate_corr_on():
|
||||
src = "source.tex"
|
||||
task = activate_corr_on(src, meta={}, output="corr_source.tex")
|
||||
assert task.action == "ACTIVATE_CORR"
|
||||
assert task.args == {}
|
||||
assert task.deps == [src]
|
||||
|
||||
|
||||
def test_build_task_compile():
|
||||
src = "source.tex"
|
||||
task = compile_pdf(src, output="source.pdf")
|
||||
assert task.action == "COMPILE"
|
||||
assert task.args == {}
|
||||
assert task.deps == [src]
|
||||
|
||||
|
||||
def test_build_task_join():
|
||||
pdfs = [f"{i}_source.pdf" for i in range(3)]
|
||||
task = join_pdfs(pdfs, output="joined.pdf")
|
||||
assert task.action == "JOIN"
|
||||
assert task.args == {}
|
||||
assert task.deps == pdfs
|
||||
|
||||
|
||||
def test_build_task_clean():
|
||||
files = ["source.aux", "source.log"]
|
||||
task = clean(files)
|
||||
assert task.action == "CLEAN"
|
||||
assert task.args == {}
|
||||
assert task.deps == files
|
40
test/test_texenv.py
Normal file
40
test/test_texenv.py
Normal file
@ -0,0 +1,40 @@
|
||||
from bopytex.jinja2_env.texenv import texenv
|
||||
|
||||
|
||||
def test_variable_block():
|
||||
base_template = r"\Var{a}"
|
||||
jinja2_template = texenv.from_string(base_template)
|
||||
output = jinja2_template.render(a=2)
|
||||
assert output == "2"
|
||||
|
||||
|
||||
def test_block_string():
|
||||
base_template = r"\Block{set a = 2}\Var{a}"
|
||||
jinja2_template = texenv.from_string(base_template)
|
||||
output = jinja2_template.render()
|
||||
assert output == "2"
|
||||
|
||||
|
||||
def test_block_line_statement():
|
||||
base_template = r"""%-set a = 2
|
||||
\Var{a}"""
|
||||
jinja2_template = texenv.from_string(base_template)
|
||||
output = jinja2_template.render()
|
||||
assert output == "2"
|
||||
|
||||
|
||||
def test_block_line_statement_with_comment():
|
||||
base_template = r"""%-set a = 2
|
||||
%# comment
|
||||
\Var{a}"""
|
||||
jinja2_template = texenv.from_string(base_template)
|
||||
output = jinja2_template.render()
|
||||
assert output == "\n2"
|
||||
|
||||
|
||||
def test_add_filter():
|
||||
texenv.filters["count_caracters"] = lambda x: len(x)
|
||||
base_template = r"""\Var{a} has \Var{a | count_caracters}"""
|
||||
jinja2_template = texenv.from_string(base_template)
|
||||
output = jinja2_template.render(a="coucou")
|
||||
assert output == "coucou has 6"
|
BIN
test/worker/source.pdf
Normal file
BIN
test/worker/source.pdf
Normal file
Binary file not shown.
36
test/worker/test_compile.py
Normal file
36
test/worker/test_compile.py
Normal file
@ -0,0 +1,36 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from bopytex.worker.compile import latexmk
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tex_path(tmp_path):
|
||||
source = tmp_path / "source.tex"
|
||||
with open(source, "w") as src:
|
||||
src.write(
|
||||
"""
|
||||
\\documentclass{article}
|
||||
|
||||
\\begin{document}
|
||||
First document. This is a simple example, with no
|
||||
extra parameters or packages included.
|
||||
\\end{document}
|
||||
"""
|
||||
)
|
||||
return source
|
||||
|
||||
|
||||
def test_latexmk(tex_path, tmp_path):
|
||||
# tmp_path = tex_path.parent
|
||||
os.chdir(tmp_path)
|
||||
|
||||
texfile = str(tex_path.name)
|
||||
output = "source.pdf"
|
||||
|
||||
message = latexmk({}, [texfile], "source.pdf")
|
||||
|
||||
assert message.status == 0
|
||||
assert Path(output).exists
|
88
test/worker/test_generate.py
Normal file
88
test/worker/test_generate.py
Normal file
@ -0,0 +1,88 @@
|
||||
import os
|
||||
|
||||
import jinja2
|
||||
import pytest
|
||||
|
||||
from bopytex.worker.generate import generate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jinja2_env(tmp_path):
|
||||
templateEnv = jinja2.Environment(loader=jinja2.FileSystemLoader(tmp_path))
|
||||
return templateEnv
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def template_path(tmp_path):
|
||||
template = tmp_path / "template.j2"
|
||||
with open(template, "w") as tpl:
|
||||
tpl.write("Plop {{ a }}")
|
||||
return template
|
||||
|
||||
|
||||
def test_generate(template_path, jinja2_env):
|
||||
tmp_path = template_path.parent
|
||||
os.chdir(tmp_path)
|
||||
|
||||
assert template_path.exists
|
||||
template = str(template_path.name)
|
||||
output = "output"
|
||||
|
||||
message = generate(
|
||||
args={
|
||||
"options": {
|
||||
"direct_access": {"a": 2},
|
||||
"jinja2": {"environment": jinja2_env},
|
||||
},
|
||||
"subject": {},
|
||||
},
|
||||
deps=[template],
|
||||
output=output,
|
||||
)
|
||||
print(message.err)
|
||||
assert message.status == 0
|
||||
assert message.out == ["GENERATE - template.j2 to output"]
|
||||
|
||||
with open(output, "r") as out:
|
||||
lines = out.readlines()
|
||||
assert lines == ["Plop 2"]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def template_path_with_random(tmp_path):
|
||||
template = tmp_path / "template.j2"
|
||||
with open(template, "w") as tpl:
|
||||
tpl.write("Plop {{ random.randint(0, 10) }}")
|
||||
return template
|
||||
|
||||
|
||||
def test_generate_with_random(template_path_with_random, jinja2_env):
|
||||
tmp_path = template_path_with_random.parent
|
||||
os.chdir(tmp_path)
|
||||
|
||||
assert template_path_with_random.exists
|
||||
template = str(template_path_with_random.name)
|
||||
output = "output"
|
||||
|
||||
import random
|
||||
|
||||
message = generate(
|
||||
args={
|
||||
"options": {
|
||||
"jinja2": {"environment": jinja2_env},
|
||||
"direct_access": {
|
||||
"random": random,
|
||||
},
|
||||
},
|
||||
"subject": {},
|
||||
},
|
||||
deps=[template],
|
||||
output=output,
|
||||
)
|
||||
print(message.err)
|
||||
assert message.status == 0
|
||||
|
||||
with open(output, "r") as out:
|
||||
lines = out.readlines()
|
||||
assert int(lines[0][-1]) >= 0
|
||||
assert int(lines[0][-1]) < 10
|
51
test/worker/test_join_pdf.py
Normal file
51
test/worker/test_join_pdf.py
Normal file
@ -0,0 +1,51 @@
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from bopytex.worker.join_pdf import pdfjam
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def multiple_pdf(tmp_path, request):
|
||||
this_file = Path(request.module.__file__)
|
||||
|
||||
source = this_file.parent / "source.pdf"
|
||||
assert source.exists()
|
||||
qty = 3
|
||||
dests = []
|
||||
for i in range(qty):
|
||||
dest = tmp_path / f"source_{i}.pdf"
|
||||
shutil.copyfile(source, dest)
|
||||
assert dest.exists()
|
||||
dests.append(dest)
|
||||
|
||||
return dests
|
||||
|
||||
|
||||
def test_join_pdf(multiple_pdf):
|
||||
tmp_path = multiple_pdf[0].parent
|
||||
os.chdir(tmp_path)
|
||||
|
||||
deps = [str(d.name) for d in multiple_pdf]
|
||||
|
||||
output = "joined.pdf"
|
||||
|
||||
message = pdfjam({"pwd": Path.cwd()}, deps, output)
|
||||
|
||||
assert message.status == 0
|
||||
assert Path(output).exists()
|
||||
|
||||
|
||||
def test_join_pdf_failed(multiple_pdf, tmp_path):
|
||||
os.chdir(tmp_path)
|
||||
|
||||
deps = [str(d.name) for d in multiple_pdf] + ["doesnotexists.pdf"]
|
||||
|
||||
output = "joined.pdf"
|
||||
|
||||
message = pdfjam({"pwd": Path.cwd()}, deps, output)
|
||||
|
||||
assert message.status == 66
|
||||
assert not Path(output).exists()
|
Loading…
Reference in New Issue
Block a user