From 1576a64ccd13ea51f096014a5a8dda48ce8652eb Mon Sep 17 00:00:00 2001 From: IDK Date: Mon, 1 Feb 2021 23:54:46 +0100 Subject: [PATCH] pylinting --- ZNotes.py | 1 - ZScolar.py | 163 +++++++++++++++++++++++--------------- pe_avislatex.py | 56 ++++++------- pe_jurype.py | 21 ++--- pe_semestretag.py | 32 ++++---- sco_apogee_csv.py | 35 +++++--- sco_bulletins_standard.py | 5 +- sco_edit_ue.py | 2 +- sco_edt_cal.py | 8 +- sco_placement.py | 7 +- sco_prepajury.py | 10 ++- sco_report.py | 2 +- sco_trombino.py | 73 +---------------- 13 files changed, 205 insertions(+), 210 deletions(-) diff --git a/ZNotes.py b/ZNotes.py index c962e6b67..bc8b54d6a 100644 --- a/ZNotes.py +++ b/ZNotes.py @@ -35,7 +35,6 @@ import pprint from sco_zope import * # pylint: disable=unused-wildcard-import # --------------- -# from sco_utils import * import sco_utils as scu import notesdb as ndb from notes_log import log, sendAlarm diff --git a/ZScolar.py b/ZScolar.py index cf4655c65..314b9bb2b 100644 --- a/ZScolar.py +++ b/ZScolar.py @@ -30,8 +30,15 @@ import sys import traceback -import time, string, glob, re -import urllib, urllib2, cgi, xml +import time +import string +import glob +import re +import urllib +import urllib2 +import cgi +import xml +import jaxml try: from cStringIO import StringIO @@ -41,7 +48,7 @@ from zipfile import ZipFile import thread import psycopg2 -from sco_zope import * +from sco_zope import * # pylint: disable=unused-wildcard-import # --------------- @@ -53,12 +60,40 @@ log("restarting...") log("ZScolar home=%s" % file_path) -from sco_utils import * -import notesdb -from notesdb import * +import sco_utils as scu +import notesdb as ndb from scolog import logdb - +from sco_permissions import ( + ScoAbsChange, + ScoView, + ScoEnsView, + ScoImplement, + ScoChangeFormation, + ScoChangePreferences, + ScoObservateur, + ScoEtudAddAnnotations, + ScoEtudInscrit, + ScoEtudChangeGroups, + ScoEtudChangeAdr, + ScoEtudSupprAnnotations, + ScoEditAllEvals, + ScoEditAllNotes, + ScoEditFormationTags, + ScoEditApo, + ScoSuperAdmin, +) +import sco_permissions +from sco_exceptions import ( + AccessDenied, + ScoException, + ScoValueError, + ScoInvalidDateError, + ScoLockedFormError, + ScoGenError, +) +from TrivialFormulator import TrivialFormulator, tf_error_message import scolars +import sco_codes_parcours import sco_preferences import sco_formations from scolars import ( @@ -110,9 +145,9 @@ import sco_dump_db from VERSION import SCOVERSION, SCONEWS -if hasattr(CONFIG, "ABSOLUTE_URL") and CONFIG.ABSOLUTE_URL: - log("ScoDoc: ABSOLUTE_URL='%s'" % CONFIG.ABSOLUTE_URL) -log("ScoDoc: using encoding %s" % SCO_ENCODING) +if hasattr(scu.CONFIG, "ABSOLUTE_URL") and scu.CONFIG.ABSOLUTE_URL: + log("ScoDoc: ABSOLUTE_URL='%s'" % scu.CONFIG.ABSOLUTE_URL) +log("ScoDoc: using encoding %s" % scu.SCO_ENCODING) # import essai_cas @@ -197,8 +232,10 @@ class ZScolar(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Imp H.append(r) ok = False - for permission in Sco_Default_Permissions.keys(): - roles = [r + DeptId for r in Sco_Default_Permissions[permission]] + for permission in sco_permissions.Sco_Default_Permissions.keys(): + roles = [ + r + DeptId for r in sco_permissions.Sco_Default_Permissions[permission] + ] roles.append("Manager") log("granting '%s' to %s" % (permission, roles)) try: @@ -271,7 +308,7 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo © Emmanuel Viennet 1997-2021

Version %s (subversion %s)

""" - % (SCOVERSION, get_svn_version(file_path)) + % (SCOVERSION, scu.get_svn_version(file_path)) ] H.append( '

Logiciel libre écrit en Python.

Utilise ReportLab pour générer les documents PDF, et pyExcelerator pour le traitement des documents Excel.

' @@ -403,7 +440,7 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo Dernières évolutions" + SCONEWS) H.append( '" ) d = "" @@ -417,12 +454,12 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo now() order by S.date_debut desc;", {"etudid": etudid}, @@ -1350,7 +1387,6 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo Date de la %s (J/M/AAAA):  """ - % (operation_method, strlower(operation_name)) + % (operation_method, scu.strlower(operation_name)) ) H.append( """ @@ -1410,7 +1446,7 @@ UE11 Découverte métiers (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo (code UCOD46, 16 ECTS, Apo " + aggregat) # listeTags = jury.get_allTagForAggregat(aggregat) # les tags de l'aggrégat listeTags = [ @@ -366,25 +369,20 @@ def get_bilanParTag(donnees_etudiant, groupe="groupe"): ("\\textit{" + rang + "}") if note else "" ) # rang masqué si pas de notes - # pprint.pprint(valeurs) - # print(len(entete)) code_latex = u"\\begin{tabular}{|c|" + "|c" * (len(entete)) + "|}\n" code_latex += u"\\hline \n" code_latex += ( u" & " - + " & ".join( - ["\\textbf{" + intitule + "}" for (agg, intitule, ordre) in entete] - ) + + " & ".join(["\\textbf{" + intitule + "}" for (agg, intitule, _) in entete]) + " \\\\ \n" ) code_latex += u"\\hline" code_latex += u"\\hline \n" for (i, ligne_val) in enumerate(valeurs["note"]): titre = lignes[i] # règle le pb d'encodage - # print titre, ligne_val code_latex += ( u"\\textbf{" - + titre.decode(SCO_ENCODING) + + titre.decode(scu.SCO_ENCODING) + u"} & " + " & ".join(ligne_val) + u"\\\\ \n" @@ -412,9 +410,11 @@ def get_avis_poursuite_par_etudiant( if pe_tools.PE_DEBUG: pe_tools.pe_print(jury.syntheseJury[etudid]["nom"] + " " + etudid) - sexe = jury.syntheseJury[etudid]["sexe"].decode(SCO_ENCODING) - nom = jury.syntheseJury[etudid]["nom"].replace(" ", "-").decode(SCO_ENCODING) - prenom = jury.syntheseJury[etudid]["prenom"].replace(" ", "-").decode(SCO_ENCODING) + sexe = jury.syntheseJury[etudid]["sexe"].decode(scu.SCO_ENCODING) + nom = jury.syntheseJury[etudid]["nom"].replace(" ", "-").decode(scu.SCO_ENCODING) + prenom = ( + jury.syntheseJury[etudid]["prenom"].replace(" ", "-").decode(scu.SCO_ENCODING) + ) nom_fichier = ( u"avis_poursuite_" @@ -460,11 +460,11 @@ def get_templates_from_distrib(template="avis"): if template in ["avis", "footer"]: # pas de preference pour le template: utilise fichier du serveur - p = os.path.join(SCO_SRCDIR, pe_local_tmpl) + p = os.path.join(scu.SCO_SRCDIR, pe_local_tmpl) if os.path.exists(p): template_latex = get_code_latex_from_modele(p) else: - p = os.path.join(SCO_SRCDIR, pe_default_tmpl) + p = os.path.join(scu.SCO_SRCDIR, pe_default_tmpl) if os.path.exists(p): template_latex = get_code_latex_from_modele(p) else: @@ -534,7 +534,9 @@ def table_syntheseAnnotationPE(context, syntheseJury, tag_annotation_pe): annotationPE = get_annotation_PE( context, etudid, tag_annotation_pe=tag_annotation_pe ) - row["Annotation PE"] = annotationPE.encode(SCO_ENCODING) if annotationPE else "" + row["Annotation PE"] = ( + annotationPE.encode(scu.SCO_ENCODING) if annotationPE else "" + ) rows.append(row) T = GenTable( diff --git a/pe_jurype.py b/pe_jurype.py index cc0002374..fe43e7d1b 100644 --- a/pe_jurype.py +++ b/pe_jurype.py @@ -42,6 +42,7 @@ Created on Fri Sep 9 09:15:05 2016 # a l'edition d'un jury de poursuites d'etudes # ---------------------------------------------------------- +import os try: from cStringIO import StringIO @@ -54,10 +55,9 @@ from zipfile import ZipFile, BadZipfile import pprint from gen_tables import GenTable, SeqGenTable - +import sco_utils as scu import sco_codes_parcours # sco_codes_parcours.NEXT -> sem suivant import sco_report -from sco_utils import * import pe_tagtable, pe_tools, pe_avislatex, pe_semestretag, pe_settag @@ -450,15 +450,15 @@ class JuryPE: end="", ) - if pe_tools.PE_DEBUG and pe_tools.PE_DEBUG >= 2: - print + # if pe_tools.PE_DEBUG and pe_tools.PE_DEBUG >= 2: + # print # ------------------------------------------------------------------------------------------------------------------ def est_un_etudiant_reoriente_ou_demissionnaire(self, etudid): """Renvoie True si l'étudiant est réorienté (NAR) ou démissionnaire (DEM)""" reponse = False etud = self.get_cache_etudInfo_d_un_etudiant(self.context, etudid) - (code, parcours) = sco_report.get_codeparcoursetud(self.context.Notes, etud) + (_, parcours) = sco_report.get_codeparcoursetud(self.context.Notes, etud) if ( len(set(sco_codes_parcours.CODES_SEM_REO.keys()) & set(parcours.values())) > 0 @@ -862,13 +862,13 @@ class JuryPE: def get_dateEntree(self, etudid): """Renvoie l'année d'entrée de l'étudiant à l'IUT""" - etudinfo = self.ETUDINFO_DICT[etudid] + # etudinfo = self.ETUDINFO_DICT[etudid] semDeb = self.get_semestresDUT_d_un_etudiant(etudid)[-1] # le 1er sem à l'IUT return semDeb["annee_debut"] def get_parcoursIUT(self, etudid): """Renvoie une liste d'infos sur les semestres du parcours d'un étudiant""" - etudinfo = self.ETUDINFO_DICT[etudid] + # etudinfo = self.ETUDINFO_DICT[etudid] sems = self.get_semestresDUT_d_un_etudiant(etudid) infos = [] @@ -1073,7 +1073,7 @@ class JuryPE: if mode == "singlesheet" else "%s " % (sem) ) - row[champ + "note"] = fmt_note(resgroupe[0]) + row[champ + "note"] = scu.fmt_note(resgroupe[0]) row[champ + "class groupe"] = "%s / %s" % ( resgroupe[2], resgroupe[3], @@ -1083,11 +1083,12 @@ class JuryPE: respromo[3], ) row[champ + "min/moy/max groupe"] = "%s / %s / %s" % tuple( - fmt_note(x) + scu.fmt_note(x) for x in (resgroupe[6], resgroupe[4], resgroupe[5]) ) row[champ + "min/moy/max promo"] = "%s / %s / %s" % tuple( - fmt_note(x) for x in (respromo[6], respromo[4], respromo[5]) + scu.fmt_note(x) + for x in (respromo[6], respromo[4], respromo[5]) ) rows.append(row) diff --git a/pe_semestretag.py b/pe_semestretag.py index cfb47ce73..919110a15 100644 --- a/pe_semestretag.py +++ b/pe_semestretag.py @@ -35,8 +35,10 @@ Created on Fri Sep 9 09:15:05 2016 @author: barasc """ -import notes_table import datetime + +from notes_log import log +import notes_table import sco_codes_parcours import sco_tag_module import sco_utils @@ -57,14 +59,14 @@ class SemestreTag(pe_tagtable.TableTag): Attributs supplémentaires : - inscrlist/identdict: étudiants inscrits hors démissionnaires ou défaillants - _tagdict : Dictionnaire résumant les tags et les modules du semestre auxquels ils sont liés - - _sum_coeff_semestre : la somme des coeffs du semestre + Attributs hérités de TableTag : - nom : - resultats: {tag: { etudid: (note_moy, somme_coff), ...} , ...} - rang - statistiques - + Redéfinition : - get_etudids() : les etudids des étudiants non défaillants ni démissionnaires """ @@ -136,8 +138,7 @@ class SemestreTag(pe_tagtable.TableTag): # ----------------------------------------------------------------------------- def get_etudids(self): - """Renvoie la liste des etud_id des étudiants inscrits au semestre - """ + """Renvoie la liste des etud_id des étudiants inscrits au semestre""" return [etud["etudid"] for etud in self.inscrlist] # ----------------------------------------------------------------------------- @@ -154,7 +155,7 @@ class SemestreTag(pe_tagtable.TableTag): Renvoie le dictionnaire ainsi construit. Rq: choix fait de repérer les modules par rapport à leur modimpl_id (valable uniquement pour un semestre), car - correspond à la majorité des calculs de moyennes pour les étudiants + correspond à la majorité des calculs de moyennes pour les étudiants (seuls ceux qui ont capitalisé des ue auront un régime de calcul différent). """ tagdict = {} @@ -227,7 +228,7 @@ class SemestreTag(pe_tagtable.TableTag): # ----------------------------------------------------------------------------- def get_noteEtCoeff_modimpl(self, modimpl_id, etudid, profondeur=2): - """ Renvoie un couple donnant la note et le coeff normalisé d'un étudiant à un module d'id modimpl_id. + """Renvoie un couple donnant la note et le coeff normalisé d'un étudiant à un module d'id modimpl_id. La note et le coeff sont extraits : 1) soit des données du semestre en normalisant le coefficient par rapport à la somme des coefficients des modules du semestre, 2) soit des données des UE précédemment capitalisées, en recherchant un module de même CODE que le modimpl_id proposé, @@ -313,10 +314,10 @@ class SemestreTag(pe_tagtable.TableTag): # ----------------------------------------------------------------------------- def get_listesNotesEtCoeffsTagEtudiant(self, tag, etudid): """Renvoie un triplet (notes, coeffs_norm, ponderations) où notes, coeff_norm et ponderation désignent trois listes - donnant -pour un tag donné- les note, coeff et ponderation de chaque modimpl à prendre en compte dans - le calcul de la moyenne du tag. - Les notes et coeff_norm sont extraits grâce à SemestreTag.get_noteEtCoeff_modimpl (donc dans semestre courant ou UE capitalisée). - Les pondérations sont celles déclarées avec le tag (cf. _tagdict). """ + donnant -pour un tag donné- les note, coeff et ponderation de chaque modimpl à prendre en compte dans + le calcul de la moyenne du tag. + Les notes et coeff_norm sont extraits grâce à SemestreTag.get_noteEtCoeff_modimpl (donc dans semestre courant ou UE capitalisée). + Les pondérations sont celles déclarées avec le tag (cf. _tagdict).""" notes = [] coeffs_norm = [] @@ -382,7 +383,7 @@ class SemestreTag(pe_tagtable.TableTag): + ( "%1.5f" % (coeff * self.somme_coeffs) if coeff != None and isinstance(coeff, float) - else str(coeff * self._sum_coeff_semestre) + else "???" # str(coeff * self._sum_coeff_semestre) # voir avec Cléo ) + delim ) @@ -471,14 +472,15 @@ def comp_coeff_pond(coeffs, ponderations): # ----------------------------------------------------------------------------- def get_moduleimpl(nt, modimpl_id): """Renvoie l'objet modimpl dont l'id est modimpl_id fourni dans la note table nt, - en utilisant l'attribut nt._modimpls""" + en utilisant l'attribut nt._modimpls""" modimplids = [ modimpl["moduleimpl_id"] for modimpl in nt._modimpls ] # la liste de id des modules (modimpl_id) if modimpl_id not in modimplids: if SemestreTag.DEBUG: - print "SemestreTag.get_moduleimpl( %s ) : le modimpl recherche n'existe pas" % ( - modimpl_id + log( + "SemestreTag.get_moduleimpl( %s ) : le modimpl recherche n'existe pas" + % (modimpl_id) ) return None return nt._modimpls[modimplids.index(modimpl_id)] diff --git a/sco_apogee_csv.py b/sco_apogee_csv.py index 45b71e927..55ccc145f 100644 --- a/sco_apogee_csv.py +++ b/sco_apogee_csv.py @@ -27,9 +27,7 @@ """Exportation des résultats des étudiants vers Apogée. -EXPERIMENTAL / PRECAUTIONS ! - -Code inspiré par les travaux de Damien Mascré, scodoc2apogee (en Java). +Ce code a été au départ inspiré par les travaux de Damien Mascré, scodoc2apogee (en Java). A utiliser en fin de semestre, après les jury. @@ -81,6 +79,13 @@ XXX A vérifier: AJAC car 1 sem. validé et pas de NAR """ + +import collections +from types import FloatType +import re +import time +import datetime +import os from cStringIO import StringIO from zipfile import ZipFile import pprint @@ -90,6 +95,10 @@ try: except: chardet_detect = None +import sco_utils as scu +import notesdb as ndb +from notes_log import log +from sco_exceptions import ScoValueError, FormatError import sco_formsemestre from sco_formsemestre import ApoEtapeVDI import sco_formsemestre_status @@ -98,8 +107,6 @@ import sco_codes_parcours from sco_codes_parcours import code_semestre_validant from sco_codes_parcours import ATT, ATB, ADM, ADC, ADJ, ATJ, ATB, AJ, CMP, NAR, RAT, DEF from gen_tables import GenTable -from notesdb import * -from sco_utils import * APO_PORTAL_ENCODING = ( "utf8" # encodage du fichier CSV Apogée (était 'ISO-8859-1' avant jul. 2016) @@ -347,10 +354,10 @@ class ApoEtud(dict): for col_id in apo_data.col_ids[:4]: self.new_cols[col_id] = self.cols[col_id] - def unassociated_codes(self, apo_data): - "list of apo elements for this student without a value in ScoDoc" - codes = set([apo_data.cols[col_id].code for col_id in apo_data.col_ids]) - return codes - set(sco_elts) + # def unassociated_codes(self, apo_data): + # "list of apo elements for this student without a value in ScoDoc" + # codes = set([apo_data.cols[col_id].code for col_id in apo_data.col_ids]) + # return codes - set(sco_elts) def search_elt_in_sem(self, context, code, sem, cur_sem, autre_sem): """ @@ -749,7 +756,7 @@ class ApoData: if not data: raise FormatError("Fichier Apogée vide !") - data_utf8 = data.decode(APO_INPUT_ENCODING).encode(SCO_ENCODING) + data_utf8 = data.decode(APO_INPUT_ENCODING).encode(scu.SCO_ENCODING) f = StringIOFileLineWrapper(data_utf8) # pour traiter comme un fichier # check that we are at the begining of Apogee CSV line = f.readline().strip() @@ -1023,7 +1030,7 @@ def _apo_read_cols(f): line = f.readline().strip(" " + APO_NEWLINE) fs = line.split(APO_SEP) if fs[0] != "apoL_a01_code": - raise FormatError("invalid line: %s (expecting apoL_a01_code)"(line, i)) + raise FormatError("invalid line: %s (expecting apoL_a01_code)" % line) col_keys = fs while True: # skip premiere partie (apoL_a02_nom, ...) @@ -1046,7 +1053,9 @@ def _apo_read_cols(f): raise FormatError("duplicate column definition: %s" % col_id) m = re.match(r"^apoL_c([0-9]{4})$", col_id) if not m: - raise FormatError("invalid column id: %s (expecting apoL_c%04d)"(line, i)) + raise FormatError( + "invalid column id: %s (expecting apoL_c%04d)" % (line, col_id) + ) if int(m.group(1)) != i: raise FormatError("invalid column id: %s for index %s" % (col_id, i)) @@ -1281,7 +1290,7 @@ def export_csv_to_apogee( ) log(logf.getvalue()) # sortie aussi sur le log ScoDoc - csv_data = f.getvalue().decode(SCO_ENCODING).encode(APO_OUTPUT_ENCODING) + csv_data = f.getvalue().decode(scu.SCO_ENCODING).encode(APO_OUTPUT_ENCODING) # Write data to ZIP dest_zip.writestr(csv_filename, csv_data) diff --git a/sco_bulletins_standard.py b/sco_bulletins_standard.py index 5bc89845b..eb937a2fd 100644 --- a/sco_bulletins_standard.py +++ b/sco_bulletins_standard.py @@ -46,7 +46,10 @@ de la forme %(XXX)s sont remplacées par la valeur de XXX, pour XXX dans: Balises img: actuellement interdites. """ -import traceback, re +import datetime +import traceback +import re +import jaxml import sco_utils as scu import sco_formsemestre diff --git a/sco_edit_ue.py b/sco_edit_ue.py index b29c613cb..4fa626240 100644 --- a/sco_edit_ue.py +++ b/sco_edit_ue.py @@ -217,7 +217,7 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None): REQUEST, ) else: - ue_id = do_ue_edit(context, tf[2]) + do_ue_edit(context, tf[2]) return REQUEST.RESPONSE.redirect( REQUEST.URL1 + "/ue_list?formation_id=" + formation_id ) diff --git a/sco_edt_cal.py b/sco_edt_cal.py index 33a70de95..c1b7554f7 100644 --- a/sco_edt_cal.py +++ b/sco_edt_cal.py @@ -84,10 +84,10 @@ def formsemestre_load_ics(context, sem): return cal -def formsemestre_edt_groups_used(context, sem): - """L'ensemble des groupes EDT utilisés dans l'emplois du temps publié""" - cal = formsemestre_load_ics(context, sem) - return {e["X-GROUP-ID"].decode("utf8") for e in events} +# def formsemestre_edt_groups_used(context, sem): +# """L'ensemble des groupes EDT utilisés dans l'emploi du temps publié""" +# cal = formsemestre_load_ics(context, sem) +# return {e["X-GROUP-ID"].decode("utf8") for e in events} def get_edt_transcodage_groups(context, formsemestre_id): diff --git a/sco_placement.py b/sco_placement.py index 62c51ec24..7917a60d4 100644 --- a/sco_placement.py +++ b/sco_placement.py @@ -31,8 +31,8 @@ Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016 """ -from notesdb import * -from sco_utils import * +import sco_utils as scu +import notesdb as ndb from notes_log import log import scolars import sco_formsemestre @@ -260,7 +260,6 @@ def do_placement(context, REQUEST): if None in [g["group_name"] for g in groups]: # tous les etudiants getallstudents = True - gr_title = "tous" gr_title_filename = "tous" else: getallstudents = False @@ -273,7 +272,7 @@ def do_placement(context, REQUEST): M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0] Mod = context.do_module_list(args={"module_id": M["module_id"]})[0] sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"]) - evalname = "%s-%s" % (Mod["code"], DateDMYtoISO(E["jour"])) + evalname = "%s-%s" % (Mod["code"], ndb.DateDMYtoISO(E["jour"])) if E["description"]: evaltitre = E["description"] else: diff --git a/sco_prepajury.py b/sco_prepajury.py index 11f33a546..16fe212f4 100644 --- a/sco_prepajury.py +++ b/sco_prepajury.py @@ -136,11 +136,17 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST): # Codes des UE "semestre précédent": ue_prev_codes = prev_moy_ue.keys() ue_prev_codes.sort( - lambda x, y, prev_ue_acro=prev_ue_acro: cmp(prev_ue_acro[x], prev_ue_acro[y]) + lambda x, y, prev_ue_acro=prev_ue_acro: cmp( # pylint: disable=undefined-variable + prev_ue_acro[x], prev_ue_acro[y] + ) ) # Codes des UE "semestre courant": ue_codes = moy_ue.keys() - ue_codes.sort(lambda x, y, ue_acro=ue_acro: cmp(ue_acro[x], ue_acro[y])) + ue_codes.sort( + lambda x, y, ue_acro=ue_acro: cmp( # pylint: disable=undefined-variable + ue_acro[x], ue_acro[y] + ) + ) sid = sem["semestre_id"] sn = sp = "" diff --git a/sco_report.py b/sco_report.py index 3f4a69b03..55927dfa5 100644 --- a/sco_report.py +++ b/sco_report.py @@ -1242,7 +1242,7 @@ def graph_parcours( dem_nodes = {} # formsemestre_id : noeud pour demissionnaires nar_nodes = {} # formsemestre_id : noeud pour NAR for etud in etuds: - nxt = None + nxt = {} etudid = etud["etudid"] for s in etud["sems"]: # du plus recent au plus ancien nt = context._getNotesCache().get_NotesTable( diff --git a/sco_trombino.py b/sco_trombino.py index 798b2368c..c4beb2296 100644 --- a/sco_trombino.py +++ b/sco_trombino.py @@ -385,8 +385,8 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST): sem = groups_infos.formsemestre # suppose 1 seul semestre PHOTOWIDTH = 2 * cm - COLWIDTH = 3.6 * cm - ROWS_PER_PAGE = 26 # XXX should be in ScoDoc preferences + # COLWIDTH = 3.6 * cm + # ROWS_PER_PAGE = 26 # XXX should be in ScoDoc preferences StyleSheet = styles.getSampleStyleSheet() report = StringIO() # in-memory document, no disk file @@ -460,71 +460,6 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST): return sendPDFFile(REQUEST, data, filename) - objects = [] - StyleSheet = styles.getSampleStyleSheet() - report = StringIO() # in-memory document, no disk file - filename = ("trombino-%s.pdf" % ng).replace( - " ", "_" - ) # XXX should sanitize this filename - objects.append( - Paragraph(SU("Liste " + sem["titreannee"] + " " + ng), StyleSheet["Heading3"]) - ) - PHOTOWIDTH = 3 * cm - COLWIDTH = 3.6 * cm - - L = [] # cells - n = 0 - currow = [] - for t in T: - n = n + 1 - img = _get_etud_platypus_image(context, t, image_width=2 * cm) - currow += [ - Paragraph( - SU( - scolars.format_sexe(t["sexe"]) - + " " - + scolars.format_prenom(t["prenom"]) - + " " - + scolars.format_nom(t["nom"]) - ), - StyleSheet["Normal"], - ), - "", # empty cell (signature ou autre info a remplir sur papier) - img, - ] - - if not L: - table = Paragraph(SU("Aucune photo à exporter !"), StyleSheet["Normal"]) - else: - table = Table( - L, - colWidths=[COLWIDTH] * 7, - style=TableStyle( - [ - ("VALIGN", (0, 0), (-1, -1), "TOP"), - ("GRID", (0, 0), (2, -1), 0.25, colors.grey), - ("GRID", (2, 0), (-1, -1), 0.25, colors.red), # <<< - ] - ), - ) - objects.append(table) - - # Réduit sur une page - objects = [KeepInFrame(0, 0, objects, mode="shrink")] - - # --- Build document - document = BaseDocTemplate(report) - document.addPageTemplates( - ScolarsPageTemplate( - document, - context=context, - preferences=context.get_preferences(sem["formsemestre_id"]), - ) - ) - document.build(objects) - data = report.getvalue() - return sendPDFFile(REQUEST, data, filename) - # --------------------- Upload des photos de tout un groupe def photos_generate_excel_sample(context, group_ids=[], REQUEST=None): @@ -614,7 +549,7 @@ def photos_import_files( def callback(context, etud, data, filename, REQUEST): sco_photos.store_photo(context, etud, data, REQUEST) - r = zip_excel_import_files( + zip_excel_import_files( context, xlsfile, zipfile, REQUEST, callback, filename_title, page_title ) return REQUEST.RESPONSE.redirect(back_url + "&head_message=photos%20 importees") @@ -638,7 +573,7 @@ def zip_excel_import_files( exceldata = xlsfile.read() if not exceldata: raise ScoValueError("Fichier excel vide ou invalide") - diag, data = sco_excel.Excel_to_list(exceldata) + _, data = sco_excel.Excel_to_list(exceldata) if not data: # probably a bug raise ScoValueError("Fichier excel vide !") # on doit avoir une colonne etudid et une colonne filename_title ('fichier_photo')