fonctionnel - a améliorer

This commit is contained in:
Jean-Marie Place 2021-09-27 07:16:30 +02:00
parent 9ee7dec202
commit 230c7d488e
2 changed files with 10 additions and 26 deletions

View File

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

View File

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