Compare commits

...

88 Commits
V0.2 ... master

Author SHA1 Message Date
Bertrand Benjamin 3c39a42562 Fix: correct README according to simple example
continuous-integration/drone/push Build is passing Details
2022-08-06 20:29:02 +02:00
Bertrand Benjamin a911b98520 Feat: produce joined_example.pdf for the two examples
continuous-integration/drone/push Build is passing Details
2022-08-06 18:04:46 +02:00
Bertrand Benjamin bf237d77e5 Feat: add make commands in README 2022-08-06 17:25:51 +02:00
Bertrand Benjamin a8d2fa2ed6 Feat: add dependencies in README 2022-08-06 17:18:09 +02:00
Bertrand Benjamin bde6c11a27 Fix: add latexmk
continuous-integration/drone/push Build is passing Details
2022-07-29 15:20:30 +02:00
Bertrand Benjamin 923cb16c66 Core: user 3.11 for drone pipeline
continuous-integration/drone/push Build encountered an error Details
2022-07-28 19:10:32 +02:00
Bertrand Benjamin 51d4d32849 Feat: add update package list first
continuous-integration/drone/push Build is failing Details
2022-07-28 15:08:15 +02:00
Bertrand Benjamin 251350f30e Feat: add install of textlive in pipelines
continuous-integration/drone/push Build is failing Details
2022-07-28 15:07:17 +02:00
Bertrand Benjamin 62253cb3ba Core: add pytest in dev-dependencies
continuous-integration/drone/push Build is failing Details
2022-07-28 15:02:27 +02:00
Bertrand Benjamin 5efc9a63ea Feat: add test and update publish for drone
continuous-integration/drone/push Build is failing Details
2022-07-28 14:58:44 +02:00
Bertrand Benjamin a0f93cc5b7 Core: add tox in dev-dependencies 2022-07-28 10:08:38 +02:00
Bertrand Benjamin 81b64c525c Core: add tox for testing 2022-07-28 10:07:21 +02:00
Bertrand Benjamin b2bbc0a24f Feat: add readmin in pyproject.toml
continuous-integration/drone/push Build is passing Details
2022-07-28 10:01:15 +02:00
Bertrand Benjamin cd2fdc162e Fix: run pre-commit hooks
continuous-integration/drone/push Build is passing Details
2022-07-28 09:39:51 +02:00
Bertrand Benjamin d5981d25e5 Core: add pre-commit config 2022-07-28 09:39:20 +02:00
Bertrand Benjamin 8a9b13cfcf Core: Add pre-commit int dev-dependencies 2022-07-28 09:29:14 +02:00
Bertrand Benjamin 18b4b69139 Core: setup poetry 2022-07-28 09:25:23 +02:00
Bertrand Benjamin d204eb19e1 Merge branch 'decoupled' into dev
continuous-integration/drone/push Build is passing Details
2022-07-20 16:46:45 +02:00
Bertrand Benjamin b5f7cdb0cf Feat: add stat for templates 2022-07-20 16:45:21 +02:00
Bertrand Benjamin ae09d37523 Feat: update README 2022-07-20 16:44:03 +02:00
Bertrand Benjamin 5bf9d8b7c1 Fix: Reading subject infos from csv file 2022-07-20 16:38:38 +02:00
Bertrand Benjamin e6595b7041 Fix: adapt examples with the new variable access 2022-07-20 16:20:21 +02:00
Bertrand Benjamin 67656c2cf1 Feat: arrange variables for templates
Split in 3 categories
- from "options" key build with default_config, file_config and cli options
- from "subject" key build csv or quantity of subject
- other in direct access from "direct_access" dictionnary inside the
  file_config
2022-07-20 16:16:09 +02:00
Bertrand Benjamin 37d779c0ab Feat: activate solution worker 2022-07-19 18:09:17 +02:00
Bertrand Benjamin 177128afe2 Feat: add a make file to run docker 2022-07-19 17:28:32 +02:00
Bertrand Benjamin b1424f096b Feat: move Dockerfile to Dockerfile.simple 2022-07-19 17:28:19 +02:00
Bertrand Benjamin 0a40e132c5 Feat: rename dockerfile from mapytex to usecase 2022-07-19 17:13:23 +02:00
Bertrand Benjamin 3d54cce718 Refact: move mapytex to usecase and build example 2022-07-19 16:37:14 +02:00
Bertrand Benjamin 473f554ebe Doc: update README with docker examples 2022-07-19 16:33:51 +02:00
Bertrand Benjamin 1fd5ca9c96 Feat: activate texenv by default 2022-07-19 16:33:27 +02:00
Bertrand Benjamin 8c20ff8e4a Feat: rename get_config 2022-07-19 15:15:06 +02:00
Bertrand Benjamin 01a0f9db17 Fix: Fix test on randint returned value 2022-05-09 09:11:56 +02:00
Bertrand Benjamin fae2afa76c Feat: make dockerfile to test my workflow 2022-05-09 09:09:38 +02:00
Bertrand Benjamin b1353bb6c7 Feat: add test with a template using random 2022-05-08 09:45:45 +02:00
Bertrand Benjamin 78f6ddc813 Feat: dockerfile to test bopytex in new environment 2022-05-08 09:15:13 +02:00
Bertrand Benjamin 8f1d9cb4d4 Feat: four un peu tout 2022-05-07 16:55:33 +02:00
Bertrand Benjamin 90ae3e936e Feat: Enable configfile loading 2022-05-05 14:35:01 +02:00
Bertrand Benjamin e4f234d241 Feat: add e2e test with failed compilation 2022-05-04 21:21:26 +02:00
Bertrand Benjamin 0d614465f0 Refact: move bopytex.bopytex to service.main 2022-05-04 21:16:27 +02:00
Bertrand Benjamin 467135abc6 Feat: Create dockerfile to test in new env 2022-05-04 18:03:58 +02:00
Bertrand Benjamin d9bd4ca5a1 Feat: Organize script to work in CLI 2022-05-04 18:00:54 +02:00
Bertrand Benjamin 9d7f779f07 Fix: Fix planer when students_csv is empty 2022-05-04 17:04:16 +02:00
Bertrand Benjamin 69b2e1c82e Refact: move config and workflow to bopytex 2022-05-04 11:39:28 +02:00
Bertrand Benjamin 87ebb4c284 Feat: add test on add_filter 2022-05-04 11:11:39 +02:00
Bertrand Benjamin 25b5bde823 Feat: Create tex jinja2 environment 2022-05-04 11:03:16 +02:00
Bertrand Benjamin 04db450ceb Feat: remise sur pieds pour les tests 2022-04-16 07:30:47 +02:00
Bertrand Benjamin ca2a47f82a Fix: empty clean worker 2022-04-16 07:14:49 +02:00
Bertrand Benjamin 1fdf223689 Feat: e2e test on default planner 2022-04-16 07:13:07 +02:00
Bertrand Benjamin 1bcbf2a9a6 core: remove tests from .gitignore 2022-04-14 11:29:39 +02:00
Bertrand Benjamin 5af4662d43 Fix: use tmp_path fixture 2022-04-13 20:41:34 +02:00
Bertrand Benjamin fe18dc4ef1 Feat: manage failing tasks in scheduler 2022-04-13 15:20:34 +02:00
Bertrand Benjamin b455ef23c4 Feat: Integrate message in service, scheduler and dispatcher 2022-04-13 15:09:08 +02:00
Bertrand Benjamin 9c05ef1551 feat: integrate message to worker 2022-04-13 12:26:04 +02:00
Bertrand Benjamin ca0f498d4e fix: list to set in typehints 2022-04-13 11:29:30 +02:00
Bertrand Benjamin 527ad160cf Feat: join_pdf work 2022-04-13 10:46:53 +02:00
Bertrand Benjamin ac8fe3dfdd Feat: latexmk worker to compile tex 2022-04-10 16:27:12 +02:00
Bertrand Benjamin 76a033cf43 feat: create generate worker 2022-04-10 16:19:41 +02:00
Bertrand Benjamin 08411bd42d Feat: move action to worker with a dispatcher 2022-04-10 14:37:19 +02:00
Bertrand Benjamin 3f1464f3f6 Feat: service work but do nothing! 2022-04-10 06:45:10 +02:00
Bertrand Benjamin abd517b339 Feat: planner generate tasks all by themselves 2022-04-09 23:00:43 +02:00
Bertrand Benjamin c89959673b refact: move planners to own directory 2022-04-09 22:46:09 +02:00
Bertrand Benjamin dfcc48dd20 refact: planners accept only options in parameters 2022-04-09 22:29:58 +02:00
Bertrand Benjamin 8c9d7bf9a2 refact: rename planner to default_planner 2022-04-09 22:06:42 +02:00
Bertrand Benjamin e52b6eb064 refact: rename bopytex to service 2022-04-09 21:53:00 +02:00
Bertrand Benjamin 963348611a Feat: scheduler don't manage actions 2022-04-09 21:46:24 +02:00
Bertrand Benjamin 1f0547c1ac doc: add docstring and typehints 2022-04-09 21:23:28 +02:00
Bertrand Benjamin 03482d4b3d Feat: add doable_task to scheduler 2022-04-09 17:08:05 +02:00
Bertrand Benjamin dc12a919d0 feat: dirty bopytex, need to test it 2022-04-09 16:18:56 +02:00
Bertrand Benjamin 374c5f7467 fix: remove comment 2022-04-09 16:16:54 +02:00
Bertrand Benjamin dca69f94aa Fix: actions typehint 2022-04-09 16:16:39 +02:00
Bertrand Benjamin 4e7805f40d Feat: add list tex files with no tpl 2022-04-09 16:08:10 +02:00
Bertrand Benjamin 7f40b7c38f feat: only_corr_planner 2022-04-09 15:42:00 +02:00
Bertrand Benjamin f9dd70a2f1 feat: planner for normal workflow 2022-04-09 15:33:28 +02:00
Bertrand Benjamin 1865f9ec63 Feat: build subjects metadatas 2022-04-09 07:30:13 +02:00
Bertrand Benjamin ebf5bd0c7d refact: rename planner to tasks 2022-04-09 06:58:44 +02:00
Bertrand Benjamin 32c74ae679 Feat: write is_finishable 2022-04-09 06:56:57 +02:00
Bertrand Benjamin 4d76dc8992 Feat: reactivate output in task 2022-04-09 06:32:56 +02:00
Bertrand Benjamin 211cee2f4f Fix: linting 2022-04-09 06:13:40 +02:00
Bertrand Benjamin 2b0c325203 feat: run the scheduler 2022-04-08 22:04:47 +02:00
Bertrand Benjamin e0377a3e92 Feat: scheduler handle dependencies (basic) 2022-04-08 21:49:18 +02:00
Bertrand Benjamin bfe9e6f91e feat: schelule multiple task 2022-04-08 21:41:29 +02:00
Bertrand Benjamin 4dbfe7a82c feat: dispatch transmit args to actions 2022-04-08 21:35:55 +02:00
Bertrand Benjamin 480ced3259 refact: remove output to tasks 2022-04-08 21:29:35 +02:00
Bertrand Benjamin 7b64dcf8d6 Feat: append, dispatch and __next__ (basic) scheduler 2022-04-08 21:24:43 +02:00
Bertrand Benjamin 6e718b987a Feat: code planners and tests 2022-04-08 19:34:38 +02:00
Bertrand Benjamin ce98f46bca Feat: clean repository 2022-04-08 19:34:22 +02:00
Bertrand Benjamin 083831acdf Feat: adapt to new mapytex 2022-01-21 16:34:17 +01:00
Bertrand Benjamin 5f0fc8bc42 Feat: only_corr works
continuous-integration/drone/push Build is passing Details
2020-11-03 10:23:18 +01:00
70 changed files with 2693 additions and 1046 deletions

View File

@ -1,13 +1,28 @@
---
kind: pipeline kind: pipeline
name: default name: default
steps: 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 - name: Publish
image: plugins/pypi image: python:3.10
settings: environment:
username: PyPI_TOKEN: pypi_token
from_secret: pypi_username commands:
password: - python -m pip install --upgrade pip
from_secret: pypi_password - python -m pip install poetry
- poetry config pypi-token.pypi $PyPI_TOKEN
- poetry publish --build
when: when:
event: tag event: tag

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
tests/
__pycache__/ __pycache__/
*.pyc *.pyc
documentation/build/ documentation/build/

20
.pre-commit-config.yaml Normal file
View 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
View 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
View 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
View 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
View File

@ -2,94 +2,149 @@
[![Build Status](https://drone.opytex.org/api/badges/lafrite/Bopytex/status.svg)](https://drone.opytex.org/lafrite/Bopytex) [![Build Status](https://drone.opytex.org/api/badges/lafrite/Bopytex/status.svg)](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 ## 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/) Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/)
pip install -U bopytex pip install -U bopytex
## Simple example ## 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 ``` latex
% tpl_example.tpl
\documentclass[12pt]{article} \documentclass[12pt]{article}
\title{Bopytex with Mapytex example -- \Var{ subject.name }}
\begin{document} \begin{document}
\section{Ajouts de fractions} \maketitle
Adding two fractions %- set e = Expression.random("{a} + {b}")
%- set e = Expression.random("{a} / {b} + {c} / {k*b}", ["b > 1", "k>1"]) \Var{e}
\[
A = \Var{e}
\]
Solution
\[
\Var{e.simplify().explain() | join('=')}
\]
\end{document}
```
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 \section{Variables}
\subsection{subject}
- `01_add_fractions.tex` \begin{itemize}
%- for k,v in subject.items()
```latex \item
\documentclass[12pt]{article} \begin{verbatim}
\Var{k}: \Var{v}
\begin{document} \end{verbatim}
%- endfor
\section{Ajouts de fractions} \end{itemize}
\subsection{options}
Adding two fractions \begin{itemize}
\[ %- for k,v in options.items()
A = \frac{- 2}{4} + \frac{7}{8} \item
\] \begin{verbatim}
Solution \Var{k}: \Var{v}
\[ \end{verbatim}
\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} %- endfor
\] \end{itemize}
\end{document} \end{document}
``` ```
- `02_add_fractions.tex` Information about my students are stored in a csv file (here `students.csv`)
```latex ``` csv
\documentclass[12pt]{article} "Name","Age","Email","fraction level","calculus level"
"Spike Tucker","22","s.tucker@randatmail.com","7","3"
\begin{document} "Martin Payne","21","m.payne@randatmail.com","7","3"
"Kimberly Baker","20","k.baker@randatmail.com","1","8"
\section{Ajouts de fractions} "Emma Bailey","29","e.bailey@randatmail.com","2","5"
"Nicholas Taylor","28","n.taylor@randatmail.com","3","3"
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}
``` ```
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

View File

@ -1,10 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: utf-8 # encoding: utf-8
#from .bopytex import subject_metadatas, crazy_feed, pdfjoin
# ----------------------------- # -----------------------------
# Reglages pour 'vim' # Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4: # vim:set autoindent expandtab tabstop=4 shiftwidth=4:

239
bopytex/bopytex.py Executable file → Normal file
View File

@ -1,237 +1,2 @@
#!/usr/bin/env python import bopytex.default_config as DEFAULT
# encoding: utf-8 from bopytex.service import orcherstrator
"""
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"solution/print = false", ans=r"solution/print = true"
):
""" Activate printanswers mod in texfile """
output_fname = "corr_" + 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

25
bopytex/default_config.py Normal file
View 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",
}

View File

@ -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

View 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

View File

@ -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

View File

@ -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
View 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

View File

View 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

View File

@ -0,0 +1,2 @@
class PlannerMissingOption(Exception):
pass

View 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"])
]

View 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
View 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
View 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()

View File

@ -2,10 +2,11 @@
# encoding: utf-8 # encoding: utf-8
import click
import logging 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") formatter = logging.Formatter("%(name)s :: %(levelname)s :: %(message)s")
steam_handler = logging.StreamHandler() steam_handler = logging.StreamHandler()
@ -15,18 +16,18 @@ logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
logger.addHandler(steam_handler) logger.addHandler(steam_handler)
@click.command() @click.command()
@click.argument( @click.argument(
"template", "template",
type=click.Path(exists=True), type=click.Path(exists=True),
nargs=1, nargs=1,
# help="File with the template. The name should have the following form tpl_... .",
) )
@click.option( @click.option(
"-w", "-w",
"--working-dir", "--working-dir",
default=".",
type=click.Path(exists=True), type=click.Path(exists=True),
help="Where fed templates and compiled files will be placed",
) )
@click.option( @click.option(
"-s", "-s",
@ -35,9 +36,6 @@ logger.addHandler(steam_handler)
default="", default="",
help="CSV containing list of students names", help="CSV containing list of students names",
) )
@click.option(
"-d", "--dirty", is_flag=True, default=False, help="Do not clean after compilation",
)
@click.option( @click.option(
"-n", "-n",
"--no-compile", "--no-compile",
@ -46,11 +44,18 @@ logger.addHandler(steam_handler)
help="Do not compile source code", help="Do not compile source code",
) )
@click.option( @click.option(
"-N", "-d",
"--number_subjects", "--dirty",
is_flag=True,
default=False,
help="Do not clean after compilation",
)
@click.option(
"-q",
"--quantity_subjects",
type=int, type=int,
default=1, default=1,
help="The number of subjects to make", help="The quantity of subjects to make",
) )
@click.option( @click.option(
"-j", "-j",
@ -64,94 +69,31 @@ logger.addHandler(steam_handler)
"--only-corr", "--only-corr",
is_flag=True, is_flag=True,
default=False, default=False,
help="Create and compile only correction from existing subjects", help="Activate correction and compile only from existing subjects",
) )
@click.option( @click.option(
"-c", "-C",
"--corr", "--corr",
is_flag=True, is_flag=True,
default=False, default=False,
help="Create and compile correction while making subjects", help="Create and compile correction while making subjects",
) )
@click.option( @click.option(
"-C", "-c",
"--crazy", "--configfile",
is_flag=True, type=str,
default=False, default="bopyptex_config.py",
help="Crazy mode. Tries and tries again until template feeding success!", help="Config file path",
) )
def new(**options): def new(**options):
""" Bopytex for message in main(**options):
try:
Feed the template (tpl_...) and then compile it with latex. assert message.status == 0
except AssertionError:
""" logger.warning(message)
setup() break
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: else:
feed( logger.info(message.out)
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)
# produce_and_compile(options)
if __name__ == "__main__": if __name__ == "__main__":

100
bopytex/service.py Executable file
View 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
View 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,
)

View 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)

View 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
View File

@ -0,0 +1,2 @@
def clean(args: dict, deps, output):
pass

26
bopytex/worker/compile.py Normal file
View 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")

View 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])

View 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),
)

View File

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

View File

@ -37,8 +37,8 @@ Sujet numéro 01
\section{Exercice} \section{Exercice}
Dans un sac, il y a 20 bonbons à la menthe, 40 bonbons à la fraise et 2 au chocolat. On choisit un bonbon au hasard dans ce sac. Dans un sac, il y a 20 bonbons à la menthe, 40 bonbons à la fraise et 2 au chocolat. On choisit un bonbon au hasard dans ce sac.
\begin{enumerate} \begin{enumerate}
\item Calculer la probabilité de tirer un bonbon à la fraise. \item Calculer la probabilité de tirer un bonbon à la fraise.
@ -47,7 +47,7 @@ Sujet numéro 01
\end{solution} \end{solution}
\item Calculer la probabilité de tirer un bonbon qui n'est pas au chocolat. \item Calculer la probabilité de tirer un bonbon qui n'est pas au chocolat.
\begin{solution} \begin{solution}
$T($ tirer un bonbon à la fraise ou à la menthe $) = \dfrac{60}{62}$ $T($ tirer un bonbon à la fraise ou à la menthe $) = \dfrac{60}{62}$
\end{solution} \end{solution}
\item Calculer la probabilité de tirer un bonbon au réglisse. \item Calculer la probabilité de tirer un bonbon au réglisse.
@ -56,18 +56,18 @@ Sujet numéro 01
\end{solution} \end{solution}
\item Dans un autre sac, on place 25 bonbons à la menthe et 34 bonbons à la fraise. Lise préfère les bonbons à la menthe. Dans quel sac doit-elle tirer un bonbon pour avoir le plus de chance d'avoir un bonbon qu'elle préfère? \item Dans un autre sac, on place 25 bonbons à la menthe et 34 bonbons à la fraise. Lise préfère les bonbons à la menthe. Dans quel sac doit-elle tirer un bonbon pour avoir le plus de chance d'avoir un bonbon qu'elle préfère?
\begin{solution} \begin{solution}
Elle prefera tirer dans le deuxième sac car Elle prefera tirer dans le deuxième sac car
\begin{eqnarray*} \begin{eqnarray*}
\frac{20}{62} & < & \frac{25}{34} \frac{20}{62} & < & \frac{25}{34}
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
\begin{enumerate} \begin{enumerate}
\item Compléter les pointillés pour qu'il y est bien égalité. \item Compléter les pointillés pour qu'il y est bien égalité.
@ -89,83 +89,83 @@ Sujet numéro 01
\item Faire les calculs suivants en détaillant les étapes (penser à simplifier les fractions quand c'est possible). \item Faire les calculs suivants en détaillant les étapes (penser à simplifier les fractions quand c'est possible).
\begin{enumerate} \begin{enumerate}
\item $A = \frac{ 10 }{ 2 } + \frac{ 8 }{ 2 }$ \item $A = \frac{ 10 }{ 2 } + \frac{ 8 }{ 2 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
A & = & \frac{ 10 }{ 2 } + \frac{ 8 }{ 2 } \\ A & = & \frac{ 10 }{ 2 } + \frac{ 8 }{ 2 } \\
A & = & \frac{ 10 + 8 }{ 2 } \\ A & = & \frac{ 10 + 8 }{ 2 } \\
A & = & 9 A & = & 9
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $B = \frac{ 6 }{ 7 } + \frac{ -5 }{ 7 }$ \item $B = \frac{ 6 }{ 7 } + \frac{ -5 }{ 7 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
B & = & \frac{ 6 }{ 7 } + \frac{ -5 }{ 7 } \\ B & = & \frac{ 6 }{ 7 } + \frac{ -5 }{ 7 } \\
B & = & \frac{ 6 - 5 }{ 7 } \\ B & = & \frac{ 6 - 5 }{ 7 } \\
B & = & \frac{ 1 }{ 7 } B & = & \frac{ 1 }{ 7 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $C = \frac{ 1 }{ 7 } + \frac{ 8 }{ 63 }$ \item $C = \frac{ 1 }{ 7 } + \frac{ 8 }{ 63 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
C & = & \frac{ 1 }{ 7 } + \frac{ 8 }{ 63 } \\ C & = & \frac{ 1 }{ 7 } + \frac{ 8 }{ 63 } \\
C & = & \frac{ 1 \times 9 }{ 7 \times 9 } + \frac{ 8 \times 1 }{ 63 \times 1 } \\ C & = & \frac{ 1 \times 9 }{ 7 \times 9 } + \frac{ 8 \times 1 }{ 63 \times 1 } \\
C & = & \frac{ 9 }{ 63 } + \frac{ 8 }{ 63 } \\ C & = & \frac{ 9 }{ 63 } + \frac{ 8 }{ 63 } \\
C & = & \frac{ 9 + 8 }{ 63 } \\ C & = & \frac{ 9 + 8 }{ 63 } \\
C & = & \frac{ 17 }{ 63 } C & = & \frac{ 17 }{ 63 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $D = \frac{ 3 }{ 2 } + \frac{ -3 }{ 16 }$ \item $D = \frac{ 3 }{ 2 } + \frac{ -3 }{ 16 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
D & = & \frac{ 3 }{ 2 } + \frac{ -3 }{ 16 } \\ D & = & \frac{ 3 }{ 2 } + \frac{ -3 }{ 16 } \\
D & = & \frac{ 3 \times 8 }{ 2 \times 8 } + \frac{ -3 \times 1 }{ 16 \times 1 } \\ D & = & \frac{ 3 \times 8 }{ 2 \times 8 } + \frac{ -3 \times 1 }{ 16 \times 1 } \\
D & = & \frac{ 24 }{ 16 } + \frac{ -3 }{ 16 } \\ D & = & \frac{ 24 }{ 16 } + \frac{ -3 }{ 16 } \\
D & = & \frac{ 24 - 3 }{ 16 } \\ D & = & \frac{ 24 - 3 }{ 16 } \\
D & = & \frac{ 21 }{ 16 } D & = & \frac{ 21 }{ 16 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $E = \frac{ 4 }{ 5 } \times 6$ \item $E = \frac{ 4 }{ 5 } \times 6$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
E & = & \frac{ 4 }{ 5 } \times 6 \\ E & = & \frac{ 4 }{ 5 } \times 6 \\
E & = & \frac{ 4 \times 6 }{ 5 } \\ E & = & \frac{ 4 \times 6 }{ 5 } \\
E & = & \frac{ 24 }{ 5 } E & = & \frac{ 24 }{ 5 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $F = \frac{ 3 }{ 7 } \times \frac{ 9 }{ 8 }$ \item $F = \frac{ 3 }{ 7 } \times \frac{ 9 }{ 8 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
F & = & \frac{ 3 }{ 7 } \times \frac{ 9 }{ 8 } \\ F & = & \frac{ 3 }{ 7 } \times \frac{ 9 }{ 8 } \\
F & = & \frac{ 9 }{ 8 } \times \frac{ 3 }{ 7 } \\ F & = & \frac{ 9 }{ 8 } \times \frac{ 3 }{ 7 } \\
F & = & \frac{ 9 \times 3 }{ 8 \times 7 } \\ F & = & \frac{ 9 \times 3 }{ 8 \times 7 } \\
F & = & \frac{ 27 }{ 56 } F & = & \frac{ 27 }{ 56 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = 8$, $OD = 15$, $CD = 2$ et $OB = 18$. Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = 8$, $OD = 15$, $CD = 2$ et $OB = 18$.
\includegraphics[scale=0.4]{thales1} \includegraphics[scale=0.4]{thales1}
Calculer les longueurs $OC$ et $AB$. Calculer les longueurs $OC$ et $AB$.
\begin{solution} \begin{solution}
On sait que On sait que
\begin{itemize} \begin{itemize}
\item $(AB)$ et $(CD)$ sont parallèles \item $(AB)$ et $(CD)$ sont parallèles
\item $A$,$O$ et $D$ sont alignés \item $A$,$O$ et $D$ sont alignés
@ -182,7 +182,7 @@ Calculer les longueurs $OC$ et $AB$.
\end{tabular} \end{tabular}
est un tableau de proportionnalité. est un tableau de proportionnalité.
On en déduit que On en déduit que
\begin{eqnarray*} \begin{eqnarray*}
OC & = & \frac{DO \times OB}{AO} = \frac{15 \times 18}{8} = 33.75 OC & = & \frac{DO \times OB}{AO} = \frac{15 \times 18}{8} = 33.75
\end{eqnarray*} \end{eqnarray*}
@ -190,13 +190,13 @@ Calculer les longueurs $OC$ et $AB$.
\begin{eqnarray*} \begin{eqnarray*}
AB & = & \frac{CD \times AO}{DO} = \frac{2 \times 8}{15} = 1.0666666666666667 AB & = & \frac{CD \times AO}{DO} = \frac{2 \times 8}{15} = 1.0666666666666667
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{document} \end{document}
%%% Local Variables: %%% Local Variables:
%%% mode: latex %%% mode: latex
%%% TeX-master: "master" %%% TeX-master: "master"
%%% End: %%% End:

View File

@ -37,8 +37,8 @@ Sujet numéro 02
\section{Exercice} \section{Exercice}
Dans un sac, il y a 10 bonbons à la menthe, 15 bonbons à la fraise et 6 au chocolat. On choisit un bonbon au hasard dans ce sac. Dans un sac, il y a 10 bonbons à la menthe, 15 bonbons à la fraise et 6 au chocolat. On choisit un bonbon au hasard dans ce sac.
\begin{enumerate} \begin{enumerate}
\item Calculer la probabilité de tirer un bonbon à la fraise. \item Calculer la probabilité de tirer un bonbon à la fraise.
@ -47,7 +47,7 @@ Sujet numéro 02
\end{solution} \end{solution}
\item Calculer la probabilité de tirer un bonbon qui n'est pas au chocolat. \item Calculer la probabilité de tirer un bonbon qui n'est pas au chocolat.
\begin{solution} \begin{solution}
$T($ tirer un bonbon à la fraise ou à la menthe $) = \dfrac{25}{31}$ $T($ tirer un bonbon à la fraise ou à la menthe $) = \dfrac{25}{31}$
\end{solution} \end{solution}
\item Calculer la probabilité de tirer un bonbon au réglisse. \item Calculer la probabilité de tirer un bonbon au réglisse.
@ -56,18 +56,18 @@ Sujet numéro 02
\end{solution} \end{solution}
\item Dans un autre sac, on place 25 bonbons à la menthe et 34 bonbons à la fraise. Lise préfère les bonbons à la menthe. Dans quel sac doit-elle tirer un bonbon pour avoir le plus de chance d'avoir un bonbon qu'elle préfère? \item Dans un autre sac, on place 25 bonbons à la menthe et 34 bonbons à la fraise. Lise préfère les bonbons à la menthe. Dans quel sac doit-elle tirer un bonbon pour avoir le plus de chance d'avoir un bonbon qu'elle préfère?
\begin{solution} \begin{solution}
Elle prefera tirer dans le deuxième sac car Elle prefera tirer dans le deuxième sac car
\begin{eqnarray*} \begin{eqnarray*}
\frac{10}{31} & < & \frac{25}{34} \frac{10}{31} & < & \frac{25}{34}
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
\begin{enumerate} \begin{enumerate}
\item Compléter les pointillés pour qu'il y est bien égalité. \item Compléter les pointillés pour qu'il y est bien égalité.
@ -89,89 +89,89 @@ Sujet numéro 02
\item Faire les calculs suivants en détaillant les étapes (penser à simplifier les fractions quand c'est possible). \item Faire les calculs suivants en détaillant les étapes (penser à simplifier les fractions quand c'est possible).
\begin{enumerate} \begin{enumerate}
\item $A = \frac{ 2 }{ 3 } + \frac{ 7 }{ 3 }$ \item $A = \frac{ 2 }{ 3 } + \frac{ 7 }{ 3 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
A & = & \frac{ 2 }{ 3 } + \frac{ 7 }{ 3 } \\ A & = & \frac{ 2 }{ 3 } + \frac{ 7 }{ 3 } \\
A & = & \frac{ 2 + 7 }{ 3 } \\ A & = & \frac{ 2 + 7 }{ 3 } \\
A & = & 3 A & = & 3
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $B = \frac{ 3 }{ 10 } + \frac{ 10 }{ 10 }$ \item $B = \frac{ 3 }{ 10 } + \frac{ 10 }{ 10 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
B & = & \frac{ 3 }{ 10 } + \frac{ 10 }{ 10 } \\ B & = & \frac{ 3 }{ 10 } + \frac{ 10 }{ 10 } \\
B & = & \frac{ 3 + 10 }{ 10 } \\ B & = & \frac{ 3 + 10 }{ 10 } \\
B & = & \frac{ 13 }{ 10 } B & = & \frac{ 13 }{ 10 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $C = \frac{ -10 }{ 6 } + \frac{ 4 }{ 12 }$ \item $C = \frac{ -10 }{ 6 } + \frac{ 4 }{ 12 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
C & = & \frac{ -10 }{ 6 } + \frac{ 4 }{ 12 } \\ C & = & \frac{ -10 }{ 6 } + \frac{ 4 }{ 12 } \\
C & = & \frac{ -10 \times 2 }{ 6 \times 2 } + \frac{ 4 \times 1 }{ 12 \times 1 } \\ C & = & \frac{ -10 \times 2 }{ 6 \times 2 } + \frac{ 4 \times 1 }{ 12 \times 1 } \\
C & = & \frac{ -20 }{ 12 } + \frac{ 4 }{ 12 } \\ C & = & \frac{ -20 }{ 12 } + \frac{ 4 }{ 12 } \\
C & = & \frac{ -20 + 4 }{ 12 } \\ C & = & \frac{ -20 + 4 }{ 12 } \\
C & = & \frac{ -16 }{ 12 } \\ C & = & \frac{ -16 }{ 12 } \\
C & = & \frac{ -4 \times 4 }{ 3 \times 4 } \\ C & = & \frac{ -4 \times 4 }{ 3 \times 4 } \\
C & = & \frac{ -4 }{ 3 } C & = & \frac{ -4 }{ 3 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $D = \frac{ 10 }{ 6 } + \frac{ -8 }{ 42 }$ \item $D = \frac{ 10 }{ 6 } + \frac{ -8 }{ 42 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
D & = & \frac{ 10 }{ 6 } + \frac{ -8 }{ 42 } \\ D & = & \frac{ 10 }{ 6 } + \frac{ -8 }{ 42 } \\
D & = & \frac{ 10 \times 7 }{ 6 \times 7 } + \frac{ -8 \times 1 }{ 42 \times 1 } \\ D & = & \frac{ 10 \times 7 }{ 6 \times 7 } + \frac{ -8 \times 1 }{ 42 \times 1 } \\
D & = & \frac{ 70 }{ 42 } + \frac{ -8 }{ 42 } \\ D & = & \frac{ 70 }{ 42 } + \frac{ -8 }{ 42 } \\
D & = & \frac{ 70 - 8 }{ 42 } \\ D & = & \frac{ 70 - 8 }{ 42 } \\
D & = & \frac{ 62 }{ 42 } \\ D & = & \frac{ 62 }{ 42 } \\
D & = & \frac{ 31 \times 2 }{ 21 \times 2 } \\ D & = & \frac{ 31 \times 2 }{ 21 \times 2 } \\
D & = & \frac{ 31 }{ 21 } D & = & \frac{ 31 }{ 21 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $E = \frac{ 6 }{ 9 } \times 4$ \item $E = \frac{ 6 }{ 9 } \times 4$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
E & = & \frac{ 6 }{ 9 } \times 4 \\ E & = & \frac{ 6 }{ 9 } \times 4 \\
E & = & \frac{ 6 \times 4 }{ 9 } \\ E & = & \frac{ 6 \times 4 }{ 9 } \\
E & = & \frac{ 24 }{ 9 } \\ E & = & \frac{ 24 }{ 9 } \\
E & = & \frac{ 8 \times 3 }{ 3 \times 3 } \\ E & = & \frac{ 8 \times 3 }{ 3 \times 3 } \\
E & = & \frac{ 8 }{ 3 } E & = & \frac{ 8 }{ 3 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $F = \frac{ 9 }{ 2 } \times \frac{ 9 }{ 5 }$ \item $F = \frac{ 9 }{ 2 } \times \frac{ 9 }{ 5 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
F & = & \frac{ 9 }{ 2 } \times \frac{ 9 }{ 5 } \\ F & = & \frac{ 9 }{ 2 } \times \frac{ 9 }{ 5 } \\
F & = & \frac{ 9 }{ 5 } \times \frac{ 9 }{ 2 } \\ F & = & \frac{ 9 }{ 5 } \times \frac{ 9 }{ 2 } \\
F & = & \frac{ 9 \times 9 }{ 5 \times 2 } \\ F & = & \frac{ 9 \times 9 }{ 5 \times 2 } \\
F & = & \frac{ 81 }{ 10 } F & = & \frac{ 81 }{ 10 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = 11$, $OD = 18$, $CD = 6$ et $OB = 14$. Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = 11$, $OD = 18$, $CD = 6$ et $OB = 14$.
\includegraphics[scale=0.4]{thales1} \includegraphics[scale=0.4]{thales1}
Calculer les longueurs $OC$ et $AB$. Calculer les longueurs $OC$ et $AB$.
\begin{solution} \begin{solution}
On sait que On sait que
\begin{itemize} \begin{itemize}
\item $(AB)$ et $(CD)$ sont parallèles \item $(AB)$ et $(CD)$ sont parallèles
\item $A$,$O$ et $D$ sont alignés \item $A$,$O$ et $D$ sont alignés
@ -188,7 +188,7 @@ Calculer les longueurs $OC$ et $AB$.
\end{tabular} \end{tabular}
est un tableau de proportionnalité. est un tableau de proportionnalité.
On en déduit que On en déduit que
\begin{eqnarray*} \begin{eqnarray*}
OC & = & \frac{DO \times OB}{AO} = \frac{18 \times 14}{11} = 22.90909090909091 OC & = & \frac{DO \times OB}{AO} = \frac{18 \times 14}{11} = 22.90909090909091
\end{eqnarray*} \end{eqnarray*}
@ -196,13 +196,13 @@ Calculer les longueurs $OC$ et $AB$.
\begin{eqnarray*} \begin{eqnarray*}
AB & = & \frac{CD \times AO}{DO} = \frac{6 \times 11}{18} = 3.666666666666667 AB & = & \frac{CD \times AO}{DO} = \frac{6 \times 11}{18} = 3.666666666666667
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{document} \end{document}
%%% Local Variables: %%% Local Variables:
%%% mode: latex %%% mode: latex
%%% TeX-master: "master" %%% TeX-master: "master"
%%% End: %%% End:

View File

@ -37,8 +37,8 @@ Sujet numéro 03
\section{Exercice} \section{Exercice}
Dans un sac, il y a 56 bonbons à la menthe, 70 bonbons à la fraise et 6 au chocolat. On choisit un bonbon au hasard dans ce sac. Dans un sac, il y a 56 bonbons à la menthe, 70 bonbons à la fraise et 6 au chocolat. On choisit un bonbon au hasard dans ce sac.
\begin{enumerate} \begin{enumerate}
\item Calculer la probabilité de tirer un bonbon à la fraise. \item Calculer la probabilité de tirer un bonbon à la fraise.
@ -47,7 +47,7 @@ Sujet numéro 03
\end{solution} \end{solution}
\item Calculer la probabilité de tirer un bonbon qui n'est pas au chocolat. \item Calculer la probabilité de tirer un bonbon qui n'est pas au chocolat.
\begin{solution} \begin{solution}
$T($ tirer un bonbon à la fraise ou à la menthe $) = \dfrac{126}{132}$ $T($ tirer un bonbon à la fraise ou à la menthe $) = \dfrac{126}{132}$
\end{solution} \end{solution}
\item Calculer la probabilité de tirer un bonbon au réglisse. \item Calculer la probabilité de tirer un bonbon au réglisse.
@ -56,18 +56,18 @@ Sujet numéro 03
\end{solution} \end{solution}
\item Dans un autre sac, on place 25 bonbons à la menthe et 34 bonbons à la fraise. Lise préfère les bonbons à la menthe. Dans quel sac doit-elle tirer un bonbon pour avoir le plus de chance d'avoir un bonbon qu'elle préfère? \item Dans un autre sac, on place 25 bonbons à la menthe et 34 bonbons à la fraise. Lise préfère les bonbons à la menthe. Dans quel sac doit-elle tirer un bonbon pour avoir le plus de chance d'avoir un bonbon qu'elle préfère?
\begin{solution} \begin{solution}
Elle prefera tirer dans le deuxième sac car Elle prefera tirer dans le deuxième sac car
\begin{eqnarray*} \begin{eqnarray*}
\frac{56}{132} & < & \frac{25}{34} \frac{56}{132} & < & \frac{25}{34}
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
\begin{enumerate} \begin{enumerate}
\item Compléter les pointillés pour qu'il y est bien égalité. \item Compléter les pointillés pour qu'il y est bien égalité.
@ -89,93 +89,93 @@ Sujet numéro 03
\item Faire les calculs suivants en détaillant les étapes (penser à simplifier les fractions quand c'est possible). \item Faire les calculs suivants en détaillant les étapes (penser à simplifier les fractions quand c'est possible).
\begin{enumerate} \begin{enumerate}
\item $A = \frac{ 2 }{ 10 } + \frac{ 2 }{ 10 }$ \item $A = \frac{ 2 }{ 10 } + \frac{ 2 }{ 10 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
A & = & \frac{ 2 }{ 10 } + \frac{ 2 }{ 10 } \\ A & = & \frac{ 2 }{ 10 } + \frac{ 2 }{ 10 } \\
A & = & \frac{ 2 + 2 }{ 10 } \\ A & = & \frac{ 2 + 2 }{ 10 } \\
A & = & \frac{ 4 }{ 10 } \\ A & = & \frac{ 4 }{ 10 } \\
A & = & \frac{ 2 \times 2 }{ 5 \times 2 } \\ A & = & \frac{ 2 \times 2 }{ 5 \times 2 } \\
A & = & \frac{ 2 }{ 5 } A & = & \frac{ 2 }{ 5 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $B = \frac{ -5 }{ 4 } + \frac{ -2 }{ 4 }$ \item $B = \frac{ -5 }{ 4 } + \frac{ -2 }{ 4 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
B & = & \frac{ -5 }{ 4 } + \frac{ -2 }{ 4 } \\ B & = & \frac{ -5 }{ 4 } + \frac{ -2 }{ 4 } \\
B & = & \frac{ -5 - 2 }{ 4 } \\ B & = & \frac{ -5 - 2 }{ 4 } \\
B & = & \frac{ -7 }{ 4 } B & = & \frac{ -7 }{ 4 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $C = \frac{ -8 }{ 2 } + \frac{ 10 }{ 16 }$ \item $C = \frac{ -8 }{ 2 } + \frac{ 10 }{ 16 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
C & = & \frac{ -8 }{ 2 } + \frac{ 10 }{ 16 } \\ C & = & \frac{ -8 }{ 2 } + \frac{ 10 }{ 16 } \\
C & = & \frac{ -8 \times 8 }{ 2 \times 8 } + \frac{ 10 \times 1 }{ 16 \times 1 } \\ C & = & \frac{ -8 \times 8 }{ 2 \times 8 } + \frac{ 10 \times 1 }{ 16 \times 1 } \\
C & = & \frac{ -64 }{ 16 } + \frac{ 10 }{ 16 } \\ C & = & \frac{ -64 }{ 16 } + \frac{ 10 }{ 16 } \\
C & = & \frac{ -64 + 10 }{ 16 } \\ C & = & \frac{ -64 + 10 }{ 16 } \\
C & = & \frac{ -54 }{ 16 } \\ C & = & \frac{ -54 }{ 16 } \\
C & = & \frac{ -27 \times 2 }{ 8 \times 2 } \\ C & = & \frac{ -27 \times 2 }{ 8 \times 2 } \\
C & = & \frac{ -27 }{ 8 } C & = & \frac{ -27 }{ 8 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $D = \frac{ -9 }{ 2 } + \frac{ -4 }{ 14 }$ \item $D = \frac{ -9 }{ 2 } + \frac{ -4 }{ 14 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
D & = & \frac{ -9 }{ 2 } + \frac{ -4 }{ 14 } \\ D & = & \frac{ -9 }{ 2 } + \frac{ -4 }{ 14 } \\
D & = & \frac{ -9 \times 7 }{ 2 \times 7 } + \frac{ -4 \times 1 }{ 14 \times 1 } \\ D & = & \frac{ -9 \times 7 }{ 2 \times 7 } + \frac{ -4 \times 1 }{ 14 \times 1 } \\
D & = & \frac{ -63 }{ 14 } + \frac{ -4 }{ 14 } \\ D & = & \frac{ -63 }{ 14 } + \frac{ -4 }{ 14 } \\
D & = & \frac{ -63 - 4 }{ 14 } \\ D & = & \frac{ -63 - 4 }{ 14 } \\
D & = & \frac{ -67 }{ 14 } D & = & \frac{ -67 }{ 14 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $E = \frac{ 5 }{ 8 } \times 4$ \item $E = \frac{ 5 }{ 8 } \times 4$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
E & = & \frac{ 5 }{ 8 } \times 4 \\ E & = & \frac{ 5 }{ 8 } \times 4 \\
E & = & \frac{ 5 \times 1 \times 4 }{ 2 \times 4 } \\ E & = & \frac{ 5 \times 1 \times 4 }{ 2 \times 4 } \\
E & = & \frac{ 5 \times 4 }{ 8 } \\ E & = & \frac{ 5 \times 4 }{ 8 } \\
E & = & \frac{ 20 }{ 8 } \\ E & = & \frac{ 20 }{ 8 } \\
E & = & \frac{ 5 \times 4 }{ 2 \times 4 } \\ E & = & \frac{ 5 \times 4 }{ 2 \times 4 } \\
E & = & \frac{ 5 }{ 2 } E & = & \frac{ 5 }{ 2 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\item $F = \frac{ 6 }{ 7 } \times \frac{ 3 }{ 8 }$ \item $F = \frac{ 6 }{ 7 } \times \frac{ 3 }{ 8 }$
\begin{solution} \begin{solution}
\begin{eqnarray*} \begin{eqnarray*}
F & = & \frac{ 6 }{ 7 } \times \frac{ 3 }{ 8 } \\ F & = & \frac{ 6 }{ 7 } \times \frac{ 3 }{ 8 } \\
F & = & \frac{ 3 }{ 8 } \times \frac{ 6 }{ 7 } \\ F & = & \frac{ 3 }{ 8 } \times \frac{ 6 }{ 7 } \\
F & = & \frac{ 3 \times 3 \times 2 }{ 4 \times 2 \times 7 } \\ F & = & \frac{ 3 \times 3 \times 2 }{ 4 \times 2 \times 7 } \\
F & = & \frac{ 3 \times 6 }{ 8 \times 7 } \\ F & = & \frac{ 3 \times 6 }{ 8 \times 7 } \\
F & = & \frac{ 18 }{ 56 } \\ F & = & \frac{ 18 }{ 56 } \\
F & = & \frac{ 9 \times 2 }{ 28 \times 2 } \\ F & = & \frac{ 9 \times 2 }{ 28 \times 2 } \\
F & = & \frac{ 9 }{ 28 } F & = & \frac{ 9 }{ 28 }
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = 3$, $OD = 7$, $CD = 5$ et $OB = 2$. Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = 3$, $OD = 7$, $CD = 5$ et $OB = 2$.
\includegraphics[scale=0.4]{thales2} \includegraphics[scale=0.4]{thales2}
Calculer les longueurs $OC$ et $AB$. Calculer les longueurs $OC$ et $AB$.
\begin{solution} \begin{solution}
On sait que On sait que
\begin{itemize} \begin{itemize}
\item $(AB)$ et $(CD)$ sont parallèles \item $(AB)$ et $(CD)$ sont parallèles
\item $A$,$O$ et $D$ sont alignés \item $A$,$O$ et $D$ sont alignés
@ -192,7 +192,7 @@ Calculer les longueurs $OC$ et $AB$.
\end{tabular} \end{tabular}
est un tableau de proportionnalité. est un tableau de proportionnalité.
On en déduit que On en déduit que
\begin{eqnarray*} \begin{eqnarray*}
OC & = & \frac{DO \times OB}{AO} = \frac{7 \times 2}{3} = 4.666666666666666 OC & = & \frac{DO \times OB}{AO} = \frac{7 \times 2}{3} = 4.666666666666666
\end{eqnarray*} \end{eqnarray*}
@ -200,13 +200,13 @@ Calculer les longueurs $OC$ et $AB$.
\begin{eqnarray*} \begin{eqnarray*}
AB & = & \frac{CD \times AO}{DO} = \frac{5 \times 3}{7} = 2.142857142857143 AB & = & \frac{CD \times AO}{DO} = \frac{5 \times 3}{7} = 2.142857142857143
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{document} \end{document}
%%% Local Variables: %%% Local Variables:
%%% mode: latex %%% mode: latex
%%% TeX-master: "master" %%% TeX-master: "master"
%%% End: %%% End:

View File

@ -59,20 +59,20 @@ Sujet numéro \Var{infos.num}
\Block{if (int(a)/total) > (25/34)} \Block{if (int(a)/total) > (25/34)}
Elle prefera tirer dans le premier sac car Elle prefera tirer dans le premier sac car
\begin{eqnarray*} \begin{eqnarray*}
\frac{\Var{a}{\Var{total}} & > & \frac{25}{34} \frac{\Var{a}{\Var{total}} & > & \frac{25}{34}
\end{eqnarray*} \end{eqnarray*}
\Block{else} \Block{else}
Elle prefera tirer dans le deuxième sac car Elle prefera tirer dans le deuxième sac car
\begin{eqnarray*} \begin{eqnarray*}
\frac{\Var{a}}{\Var{total}} & < & \frac{25}{34} \frac{\Var{a}}{\Var{total}} & < & \frac{25}{34}
\end{eqnarray*} \end{eqnarray*}
\Block{endif} \Block{endif}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
\begin{enumerate} \begin{enumerate}
\item Compléter les pointillés pour qu'il y est bien égalité. \item Compléter les pointillés pour qu'il y est bien égalité.
@ -137,23 +137,23 @@ Sujet numéro \Var{infos.num}
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{enumerate} \end{enumerate}
\end{enumerate} \end{enumerate}
\section{Exercice} \section{Exercice}
\Block{set AO, OD, CD, OB = random_str("{a},{b},{c},{d}", ["{a} < {b}", "{c} != {d}"], 1, 20).split(',')} \Block{set AO, OD, CD, OB = random_str("{a},{b},{c},{d}", ["{a} < {b}", "{c} != {d}"], 1, 20).split(',')}
Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = \Var{AO}$, $OD = \Var{OD}$, $CD = \Var{CD}$ et $OB = \Var{OB}$. Dans la figure suivante, $(AB)$ et $(CD)$ sont parallèles, $AO = \Var{AO}$, $OD = \Var{OD}$, $CD = \Var{CD}$ et $OB = \Var{OB}$.
\Block{set fig = random_str("{a}", [], 1, 2)} \Block{set fig = random_str("{a}", [], 1, 2)}
\includegraphics[scale=0.4]{thales\Var{fig}} \includegraphics[scale=0.4]{thales\Var{fig}}
Calculer les longueurs $OC$ et $AB$. Calculer les longueurs $OC$ et $AB$.
\begin{solution} \begin{solution}
On sait que On sait que
\begin{itemize} \begin{itemize}
\item $(AB)$ et $(CD)$ sont parallèles \item $(AB)$ et $(CD)$ sont parallèles
\item $A$,$O$ et $D$ sont alignés \item $A$,$O$ et $D$ sont alignés
@ -170,7 +170,7 @@ Calculer les longueurs $OC$ et $AB$.
\end{tabular} \end{tabular}
est un tableau de proportionnalité. est un tableau de proportionnalité.
On en déduit que On en déduit que
\begin{eqnarray*} \begin{eqnarray*}
OC & = & \frac{DO \times OB}{AO} = \frac{\Var{OD} \times \Var{OB}}{\Var{AO}} = \Var{int(OD)*int(OB)/int(AO) | round(2)} OC & = & \frac{DO \times OB}{AO} = \frac{\Var{OD} \times \Var{OB}}{\Var{AO}} = \Var{int(OD)*int(OB)/int(AO) | round(2)}
\end{eqnarray*} \end{eqnarray*}
@ -178,14 +178,13 @@ Calculer les longueurs $OC$ et $AB$.
\begin{eqnarray*} \begin{eqnarray*}
AB & = & \frac{CD \times AO}{DO} = \frac{\Var{CD} \times \Var{AO}}{\Var{OD}} = \Var{int(CD)*int(AO)/int(OD) |round(2)} AB & = & \frac{CD \times AO}{DO} = \frac{\Var{CD} \times \Var{AO}}{\Var{OD}} = \Var{int(CD)*int(AO)/int(OD) |round(2)}
\end{eqnarray*} \end{eqnarray*}
\end{solution} \end{solution}
\end{document} \end{document}
%%% Local Variables: %%% Local Variables:
%%% mode: latex %%% mode: latex
%%% TeX-master: "master" %%% TeX-master: "master"
%%% End: %%% End:

View File

@ -13,70 +13,70 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys
import os import os
import shlex import shlex
import sys
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # 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 ------------------------------------------------ # -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # 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 # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
'sphinx.ext.autodoc', "sphinx.ext.autodoc",
'sphinx.ext.mathjax', "sphinx.ext.mathjax",
'sphinx.ext.ifconfig', "sphinx.ext.ifconfig",
'sphinx.ext.viewcode', "sphinx.ext.viewcode",
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ["_templates"]
# The suffix(es) of source filenames. # The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string: # You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md'] # source_suffix = ['.rst', '.md']
source_suffix = '.rst' source_suffix = ".rst"
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = "index"
# General information about the project. # General information about the project.
project = 'Opytex' project = "Opytex"
copyright = '2016, Benjamin Bertrand' copyright = "2016, Benjamin Bertrand"
author = 'Benjamin Bertrand' author = "Benjamin Bertrand"
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.1' version = "0.1"
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1' release = "0.1"
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
# #
# This is also used if you do content translation via gettext catalogs. # This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases. # Usually you set "language" from the command line for these cases.
language = 'fr' language = "fr"
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' # today = ''
# Else, today_fmt is used as the format for a strftime call. # 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 # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # 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 # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
#default_role = None # default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # 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 # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True # add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
#modindex_common_prefix = [] # modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents. # 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. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False 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 # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
#html_theme = 'alabaster' # html_theme = 'alabaster'
import sphinx_rtd_theme import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme" html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# Theme options are theme-specific and customize the look and feel of a theme # 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 # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} # html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory. # 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 # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
#html_title = None # html_title = None
# A shorter title for the navigation bar. Default is the same as html_title. # 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 # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # 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 # 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 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = None # html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation. # 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, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # 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 # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True # html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # 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 # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} # html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True # html_domain_indices = True
# If false, no index is generated. # 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. # 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. # 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. # 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. # 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 # 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 # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # 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"). # 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. # Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages: # Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' # '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. # A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value # 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 # The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used. # 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. # Output file base name for HTML help builder.
htmlhelp_basename = 'Opytexdoc' htmlhelp_basename = "Opytexdoc"
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', #'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt',
#'pointsize': '10pt', # Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble. # Latex figure (float) alignment
#'preamble': '', #'figure_align': 'htbp',
# Latex figure (float) alignment
#'figure_align': 'htbp',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'Opytex.tex', 'Opytex Documentation', (master_doc, "Opytex.tex", "Opytex Documentation", "Benjamin Bertrand", "manual"),
'Benjamin Bertrand', 'manual'),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None # latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False # latex_use_parts = False
# If true, show page references after internal links. # If true, show page references after internal links.
#latex_show_pagerefs = False # latex_show_pagerefs = False
# If true, show URL addresses after external links. # 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. # Documents to append as an appendix to all manuals.
#latex_appendices = [] # latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_domain_indices = True # latex_domain_indices = True
# -- Options for manual page output --------------------------------------- # -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [(master_doc, "opytex", "Opytex Documentation", [author], 1)]
(master_doc, 'opytex', 'Opytex Documentation',
[author], 1)
]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False # man_show_urls = False
# -- Options for Texinfo output ------------------------------------------- # -- Options for Texinfo output -------------------------------------------
@ -275,19 +269,25 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'Opytex', 'Opytex Documentation', (
author, 'Opytex', 'One line description of project.', master_doc,
'Miscellaneous'), "Opytex",
"Opytex Documentation",
author,
"Opytex",
"One line description of project.",
"Miscellaneous",
),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#texinfo_appendices = [] # texinfo_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#texinfo_domain_indices = True # texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'. # 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. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False # texinfo_no_detailmenu = False

View File

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

View File

@ -69,7 +69,7 @@ Simplifications de fractions
Explications Explications
\begin{align*} \begin{align*}
\Var{f.simplify().explain()|join('=')} \Var{f.simplify().explain()|join('=')}
\end{align*} \end{align*}
Ce qui produira Ce qui produira
@ -84,9 +84,9 @@ Simplifications de fractions
\dfrac{12}{9} = \dfrac{4}{3} \dfrac{12}{9} = \dfrac{4}{3}
\end{align*} \end{align*}
Explications Explications
\begin{align*} \begin{align*}
\frac{ 12 }{ 9 }=\frac{ 4 \times 3 }{ 3 \times 3 }=\frac{ 4 }{ 3 } \frac{ 12 }{ 9 }=\frac{ 4 \times 3 }{ 3 \times 3 }=\frac{ 4 }{ 3 }
\end{align*} \end{align*}
Et ce qui donne Et ce qui donne
@ -104,9 +104,9 @@ Simplifications de fractions
\end{align*} \end{align*}
Explications Explications
\begin{align*} \begin{align*}
\frac{ 12 }{ 9 }=\frac{ 4 \times 3 }{ 3 \times 3 }=\frac{ 4 }{ 3 } \frac{ 12 }{ 9 }=\frac{ 4 \times 3 }{ 3 \times 3 }=\frac{ 4 }{ 3 }
\end{align*} \end{align*}

View File

@ -67,7 +67,7 @@ Ce qui produira
i vaut 3 i vaut 3
i vaut 4 i vaut 4
Quelques commandes supplémentaires Quelques commandes supplémentaires
================================== ==================================
@ -84,7 +84,7 @@ Filtres qui marchenet bien avec Mapytex
\Block{set e = Expression("1 + 2*3")} \Block{set e = Expression("1 + 2*3")}
et on veut détailler sa simplification et on veut détailler sa simplification
\begin{align*} \begin{align*}
\Var{e.simplify().explain()|join('=')} \Var{e.simplify().explain()|join('=')}
\end{align*} \end{align*}
@ -95,7 +95,7 @@ Filtres qui marchenet bien avec Mapytex
On commence par définir une expression, On commence par définir une expression,
et on veut détailler sa simplification et on veut détailler sa simplification
\begin{align*} \begin{align*}
1 + 2 \times 3 = 1 + 6 = 7 1 + 2 \times 3 = 1 + 6 = 7
\end{align*} \end{align*}
@ -108,7 +108,7 @@ Filtres qui marchenet bien avec Mapytex
\Block{set e = Expression("1 + 2*3")} \Block{set e = Expression("1 + 2*3")}
et on veut détailler sa simplification et on veut détailler sa simplification
\begin{eqnarray*} \begin{eqnarray*}
\Var{e.simplify().explain()|calculus(name = 'e')} \Var{e.simplify().explain()|calculus(name = 'e')}
\end{eqnarray*} \end{eqnarray*}
@ -121,10 +121,10 @@ Filtres qui marchenet bien avec Mapytex
\begin{eqnarray*} \begin{eqnarray*}
e & = & 1 + 2 \times 3 \\ e & = & 1 + 2 \times 3 \\
e & = & 1 + 6 \\ e & = & 1 + 6 \\
e & = & 7 e & = & 7
\end{eqnarray*} \end{eqnarray*}
Compilation des documents Compilation des documents
========================= =========================
@ -136,7 +136,7 @@ Puis on génère et compile les 3 sujets avec la commande
opytex -t tpl_DM.tex -N 3 opytex -t tpl_DM.tex -N 3
Ce qui a crée les fichiers sources: Ce qui a crée les fichiers sources:
- :download:`01_DM.tex <_downloads/01_DM.tex>` - :download:`01_DM.tex <_downloads/01_DM.tex>`
- :download:`02_DM.tex <_downloads/02_DM.tex>` - :download:`02_DM.tex <_downloads/02_DM.tex>`
@ -158,6 +158,3 @@ Il est possible aussi de créer les sujets et les corrections en même temps ave
.. code-block:: bash .. code-block:: bash
opytex -t tpl_DM.tex -c -N 60 opytex -t tpl_DM.tex -c -N 60

Binary file not shown.

View 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}

View File

@ -0,0 +1,7 @@
import random
from mapytex import Expression
random.seed(0)
direct_access = {"Expression": Expression, "random": random.random}

Binary file not shown.

View 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"
1 Name Age Email fraction level calculus level
2 Spike Tucker 22 s.tucker@randatmail.com 7 3
3 Martin Payne 21 m.payne@randatmail.com 7 3
4 Kimberly Baker 20 k.baker@randatmail.com 1 8
5 Emma Bailey 29 e.bailey@randatmail.com 2 5
6 Nicholas Taylor 28 n.taylor@randatmail.com 3 3

View 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}

View File

@ -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
View 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
View 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"

View File

@ -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

View File

@ -4,21 +4,18 @@
from setuptools import setup from setuptools import setup
setup( setup(
name='Bopytex', name="Bopytex",
version='0.2', version="0.9",
description='Command line tool for compiling latex with python command embedded', description="Command line tool for compiling latex with python command embedded",
author='Benjamin Bertrand', author="Benjamin Bertrand",
author_email='programming@opytex.org', author_email="benjamin.bertrand@opytex.org",
packages=['bopytex'], packages=["bopytex"],
install_requires=[ install_requires=[
'mapytex', "click",
'mypytex', "jinja2",
'click', ],
], entry_points={"console_scripts": ["bopytex=bopytex.script:new"]},
entry_points={ )
"console_scripts": ['bopytex=bopytex.script:new']
},
)
# ----------------------------- # -----------------------------
# Reglages pour 'vim' # Reglages pour 'vim'

0
test/__init__.py Normal file
View File

0
test/fakes/__init__.py Normal file
View File

11
test/fakes/dispatcher.py Normal file
View 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
View 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
View 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}"], [])

View File

@ -1,6 +0,0 @@
nom,classe,elo
Bob,1ST,1000
Pipo,1ST,1300
Popi,1ST,100
Boule,1ST,4000
Bill,1ST,1300
1 nom classe elo
2 Bob 1ST 1000
3 Pipo 1ST 1300
4 Popi 1ST 100
5 Boule 1ST 4000
6 Bill 1ST 1300

View File

@ -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}

View File

@ -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
View 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
View 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
View 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
View 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
View 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
View 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

Binary file not shown.

View 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

View 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

View 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()

11
tox.ini Normal file
View File

@ -0,0 +1,11 @@
[tox]
isolated_build = True
envlist = py310
[testenv]
deps =
black
pytest
commands =
black --check bopytex
pytest .