From 230c7d488e89d01a85edd29152ec7bab6572b2b7 Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Mon, 27 Sep 2021 07:16:30 +0200 Subject: [PATCH] =?UTF-8?q?fonctionnel=20-=20a=20am=C3=A9liorer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pe/pe_tools.py | 13 +++++-------- app/pe/pe_view.py | 23 +++++------------------ 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/app/pe/pe_tools.py b/app/pe/pe_tools.py index 4df97cfc..d54de1d8 100644 --- a/app/pe/pe_tools.py +++ b/app/pe/pe_tools.py @@ -53,8 +53,6 @@ if not PE_DEBUG: def pe_print(*a, **kw): # kw is ignored. log always add a newline log(" ".join(a)) - - else: pe_print = print # print function @@ -164,13 +162,12 @@ def list_directory_filenames(path): return R -def add_local_file_to_zip(zipfile, ziproot, pathname, path_in_zip, mode='r'): +def add_local_file_to_zip(zipfile, ziproot, pathname, path_in_zip): """Read pathname server file and add content to zip under path_in_zip""" rooted_path_in_zip = os.path.join(ziproot, path_in_zip) - breakpoint() - with open(rooted_path_in_zip, mode=mode) as f: - data = f.read() - zipfile.writestr(rooted_path_in_zip, data) + zipfile.write(filename=pathname, arcname=rooted_path_in_zip) + # data = open(pathname).read() + # zipfile.writestr(rooted_path_in_zip, data) def add_pe_stuff_to_zip(zipfile, ziproot): @@ -211,7 +208,7 @@ def add_pe_stuff_to_zip(zipfile, ziproot): for f in logos_names: logo = os.path.join(scu.SCODOC_LOGOS_DIR, f) if os.path.isfile(logo): - add_local_file_to_zip(zipfile, ziproot, logo, "avis/logos/" + f, mode='rb') + add_local_file_to_zip(zipfile, ziproot, logo, "avis/logos/" + f) # ---------------------------------------------------------------------------------------- diff --git a/app/pe/pe_view.py b/app/pe/pe_view.py index f44e1386..15f8f6f8 100644 --- a/app/pe/pe_view.py +++ b/app/pe/pe_view.py @@ -89,7 +89,6 @@ def pe_view_sem_recap( semBase = sco_formsemestre.get_formsemestre(formsemestre_id) jury = pe_jurype.JuryPE(semBase) - # Ajout avis LaTeX au même zip: etudids = list(jury.syntheseJury.keys()) @@ -118,15 +117,11 @@ def pe_view_sem_recap( footer_latex = footer_tmpl_file.read() footer_latex = footer_latex else: - footer_latex = pe_avislatex.get_code_latex_from_scodoc_preference( - formsemestre_id, champ="pe_avis_latex_footer" - ) + footer_latex = pe_avislatex.get_code_latex_from_scodoc_preference(formsemestre_id, champ="pe_avis_latex_footer") footer_latex = footer_latex.strip() if not footer_latex: # pas de preference pour le footer: utilise fichier du serveur - footer_latex = pe_avislatex.get_templates_from_distrib( - "footer" - ) # fallback: footer vides + footer_latex = pe_avislatex.get_templates_from_distrib("footer") # fallback: footer vides tag_annotation_pe = pe_avislatex.get_code_latex_from_scodoc_preference( formsemestre_id, champ="pe_tag_annotation_avis_latex" @@ -135,9 +130,7 @@ def pe_view_sem_recap( # Ajout des annotations PE dans un fichier excel sT = pe_avislatex.table_syntheseAnnotationPE(jury.syntheseJury, tag_annotation_pe) if sT: - jury.add_file_to_zip( - jury.NOM_EXPORT_ZIP + "_annotationsPE" + scu.XLSX_SUFFIX, sT.excel() - ) + jury.add_file_to_zip(jury.NOM_EXPORT_ZIP + "_annotationsPE" + scu.XLSX_SUFFIX, sT.excel()) latex_pages = {} # Dictionnaire de la forme nom_fichier => contenu_latex for etudid in etudids: @@ -149,17 +142,11 @@ def pe_view_sem_recap( footer_latex, prefs, ) - - jury.add_file_to_zip( - "avis/" + nom_fichier + ".tex", - contenu_latex, - ) + jury.add_file_to_zip("avis/" + nom_fichier + ".tex", contenu_latex) latex_pages[nom_fichier] = contenu_latex # Sauvegarde dans un dico # Nouvelle version : 1 fichier par étudiant avec 1 fichier appelant créée ci-dessous - doc_latex = "\n% -----\n".join( - ["\\include{" + nom + "}" for nom in sorted(latex_pages.keys())] - ) + doc_latex = "\n% -----\n".join(["\\include{" + nom + "}" for nom in sorted(latex_pages.keys())]) jury.add_file_to_zip("avis/avis_poursuite.tex", doc_latex) # Ajoute image, LaTeX class file(s) and modeles