#!/usr/bin/env python # encoding: utf-8 import os, jinja2 import subprocess import shlex from add_frac import type1, type3, type4 from call_litt import fullExo as exo2 #classes = {"4C" : [], "4D": []} classes = {"4C": []} def build_student(infos): return {'nom':infos[1].capitalize(), "prenom": infos[2].capitalize(), "classe" : infos[0], "frac1" : type1(), "frac3" : type3(), "frac4" : type4(), "exo2" : exo2()} 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_dec3.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_dec3_{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})) proc=subprocess.Popen(shlex.split("pdflatex DM_dec3_{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