74 lines
1.8 KiB
Python
74 lines
1.8 KiB
Python
|
#!/usr/bin/env python
|
||
|
# encoding: utf-8
|
||
|
|
||
|
import os, jinja2
|
||
|
import subprocess
|
||
|
import shlex
|
||
|
from rd_fact import fact
|
||
|
|
||
|
#classes = {"4C" : [], "4D": []}
|
||
|
classes = {"3B": []}
|
||
|
|
||
|
def build_student(infos):
|
||
|
return {'nom':infos[1].capitalize(),
|
||
|
"prenom": infos[2].capitalize(),
|
||
|
"classe" : infos[0]}
|
||
|
|
||
|
with open('./comptes_eleves_LaboMEP.csv', 'r', encoding="latin1") as accounts_f:
|
||
|
for line in accounts_f:
|
||
|
line_l = line.split(";")
|
||
|
if line_l[0] in classes:
|
||
|
classes[line_l[0]] += [build_student(line_l)]
|
||
|
|
||
|
report_renderer = jinja2.Environment(
|
||
|
block_start_string = '%{',
|
||
|
block_end_string = '%}',
|
||
|
variable_start_string = '%{{',
|
||
|
variable_end_string = '%}}',
|
||
|
loader = jinja2.FileSystemLoader(os.path.abspath('.'))
|
||
|
)
|
||
|
template = report_renderer.get_template("./DM_janv2.tex")
|
||
|
|
||
|
for (classe, eleves) in classes.items():
|
||
|
path = "./"+classe
|
||
|
|
||
|
if not os.path.exists(path):
|
||
|
os.mkdir("./" + classe)
|
||
|
|
||
|
os.chdir("./" + classe)
|
||
|
|
||
|
i = 0
|
||
|
while i < len(eleves):
|
||
|
dest_file= "./DM_janv2_{i}.tex".format(i = int(i/2))
|
||
|
print(dest_file)
|
||
|
|
||
|
if i <= len(eleves) - 2:
|
||
|
eleve1 = eleves[i]
|
||
|
eleve2 = eleves[i+1]
|
||
|
#deux_eleves = mixing(eleves[i], eleves[i+1])
|
||
|
else:
|
||
|
eleve1 = eleves[i]
|
||
|
eleve2 = eleves[i]
|
||
|
#deux_eleves = mixing(eleves[i])
|
||
|
|
||
|
|
||
|
|
||
|
with open(dest_file, 'w') as f:
|
||
|
f.write(template.render({"eleve1" : eleve1, "eleve2" :eleve2, "fact": fact}))
|
||
|
|
||
|
proc=subprocess.Popen(shlex.split("pdflatex DM_janv2_{i}".format(i = int(i/2))))
|
||
|
proc.communicate()
|
||
|
|
||
|
i += 2
|
||
|
|
||
|
os.chdir("..")
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
# -----------------------------
|
||
|
# Reglages pour 'vim'
|
||
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||
|
# cursor: 16 del
|