From 8d8b8a3ae94964cb9037600ba01d37376e66f711 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 9 Jul 2021 23:31:16 +0200 Subject: [PATCH] New-Style Classes --- app/scodoc/TrivialFormulator.py | 2 +- app/scodoc/debug.py | 6 +++--- app/scodoc/gen_tables.py | 6 +++--- app/scodoc/notes_log.py | 2 +- app/scodoc/notes_table.py | 2 +- app/scodoc/notesdb.py | 2 +- app/scodoc/pe_jurype.py | 2 +- app/scodoc/pe_tagtable.py | 2 +- app/scodoc/sco_abs.py | 4 ++-- app/scodoc/sco_apogee_csv.py | 6 +++--- app/scodoc/sco_archives.py | 2 +- app/scodoc/sco_bac.py | 2 +- app/scodoc/sco_bulletins_generator.py | 2 +- app/scodoc/sco_bulletins_legacy.py | 2 +- app/scodoc/sco_cache.py | 2 +- app/scodoc/sco_codes_parcours.py | 8 +++++--- app/scodoc/sco_core.py | 9 +++++++-- app/scodoc/sco_etape_bilan.py | 4 ++-- app/scodoc/sco_etud.py | 2 +- app/scodoc/sco_excel.py | 2 +- app/scodoc/sco_formsemestre.py | 2 +- app/scodoc/sco_groups.py | 2 +- app/scodoc/sco_groups_view.py | 2 +- app/scodoc/sco_news.py | 2 +- app/scodoc/sco_parcours_dut.py | 4 ++-- app/scodoc/sco_pdf.py | 2 +- app/scodoc/sco_permissions.py | 2 +- app/scodoc/sco_portal_apogee.py | 14 ++++++++++---- app/scodoc/sco_report.py | 2 +- app/scodoc/sco_tag_module.py | 2 +- app/scodoc/sco_utils.py | 2 +- config/scodoc_config.py | 2 +- config/scodoc_config_tmpl.py | 2 +- scodoc_manager.py | 7 ++++++- scotests/sco_fake_gen.py | 2 +- 35 files changed, 68 insertions(+), 50 deletions(-) diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index c0b1e473..b86b1ae4 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -113,7 +113,7 @@ def TrivialFormulator( return res, form, t.result -class TF: +class TF(object): def __init__( self, form_url, diff --git a/app/scodoc/debug.py b/app/scodoc/debug.py index 456b1363..cd14b33c 100644 --- a/app/scodoc/debug.py +++ b/app/scodoc/debug.py @@ -92,7 +92,7 @@ def go_dept(app, dept, verbose=True): raise ValueError("dep %s not found" % dept) -class FakeUser: +class FakeUser(object): def __init__(self, name): self.name = name @@ -106,7 +106,7 @@ class FakeUser: return True -class DummyResponse: +class DummyResponse(object): """Emulation vide de Reponse http Zope""" def __init__(self): @@ -120,7 +120,7 @@ class DummyResponse: self.redirected = url -class DummyRequest: +class DummyRequest(object): """Emulation vide de Request Zope""" def __init__(self): diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 7f15dc82..1931bad7 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -72,7 +72,7 @@ def mark_paras(L, tags): return L -class DEFAULT_TABLE_PREFERENCES: +class DEFAULT_TABLE_PREFERENCES(object): """Default preferences for tables created without preferences argument""" values = { @@ -85,7 +85,7 @@ class DEFAULT_TABLE_PREFERENCES: return self.values[k] -class GenTable: +class GenTable(object): """Simple 2D tables with export to HTML, PDF, Excel, CSV. Can be sub-classed to generate fancy formats. """ @@ -679,7 +679,7 @@ class GenTable: # ----- -class SeqGenTable: +class SeqGenTable(object): """Sequence de GenTable: permet de générer un classeur excel avec un tab par table. L'ordre des tabs est conservé (1er tab == 1ere table ajoutée) """ diff --git a/app/scodoc/notes_log.py b/app/scodoc/notes_log.py index 47112269..f2811491 100644 --- a/app/scodoc/notes_log.py +++ b/app/scodoc/notes_log.py @@ -20,7 +20,7 @@ DEFAULT_LOG_DIR = "/tmp" # clients should call set_log_directory to change this ALARM_DESTINATION = "emmanuel.viennet@univ-paris13.fr" # XXX a mettre en preference -class _logguer: +class _logguer(object): def __init__(self): self.file = None self.directory = None diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index 3ab5aa60..270dc5bb 100644 --- a/app/scodoc/notes_table.py +++ b/app/scodoc/notes_table.py @@ -153,7 +153,7 @@ def comp_etud_sum_coef_modules_ue(context, formsemestre_id, etudid, ue_id): return s -class NotesTable: +class NotesTable(object): """Une NotesTable représente un tableau de notes pour un semestre de formation. Les colonnes sont des modules. Les lignes des étudiants. diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index 3df2fd46..da1e5275 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -253,7 +253,7 @@ def DBDelete(cnx, table, colid, val, commit=False): # REQN = 0 -class EditableTable: +class EditableTable(object): """--- generic class: SQL table with create/edit/list/delete""" def __init__( diff --git a/app/scodoc/pe_jurype.py b/app/scodoc/pe_jurype.py index 55bf2601..74c8f3b4 100644 --- a/app/scodoc/pe_jurype.py +++ b/app/scodoc/pe_jurype.py @@ -85,7 +85,7 @@ def comp_nom_semestre_dans_parcours(context, sem): # ---------------------------------------------------------------------------------------- -class JuryPE: +class JuryPE(object): """Classe memorisant toutes les informations necessaires pour etablir un jury de PE. Modele base sur NotesTable diff --git a/app/scodoc/pe_tagtable.py b/app/scodoc/pe_tagtable.py index e8df575a..850832b9 100644 --- a/app/scodoc/pe_tagtable.py +++ b/app/scodoc/pe_tagtable.py @@ -42,7 +42,7 @@ import datetime from app.scodoc import notes_table -class TableTag: +class TableTag(object): """ Classe mémorisant les moyennes des étudiants à différents tag et permettant de calculer les rangs et les statistiques : - nom : Nom représentatif des données de la Table diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 7c8b42e7..beba4155 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -84,7 +84,7 @@ def MonthNbDays(month, year): return 30 -class ddmmyyyy: +class ddmmyyyy(object): """immutable dates""" def __init__(self, date=None, fmt="ddmmyyyy", work_saturday=False): @@ -987,7 +987,7 @@ def MonthTableBody( # absences à une date donnée). # # -------------------------------------------------------------------- -class CAbsSemEtud: +class CAbsSemEtud(object): """Comptes d'absences d'un etudiant dans un semestre""" def __init__(self, context, sem, etudid): diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index 540da23c..974ce478 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -220,7 +220,7 @@ class DictCol(dict): pass -class ApoElt: +class ApoElt(object): """Definition d'un Element Apogee sur plusieurs colonnes du fichier CSV """ @@ -248,7 +248,7 @@ class ApoElt: return "ApoElt(code='%s', cols=%s)" % (self.code, pprint.pformat(self.cols)) -class EtuCol: +class EtuCol(object): """Valeurs colonnes d'un element pour un etudiant""" def __init__(self, nip, apo_elt, init_vals): @@ -669,7 +669,7 @@ class ApoEtud(dict): return cur_sem, autre_sem -class ApoData: +class ApoData(object): def __init__( self, data, diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index 2770bcad..7891f019 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -70,7 +70,7 @@ from app.scodoc import sco_pvjury from app.scodoc import sco_pvpdf -class BaseArchiver: +class BaseArchiver(object): def __init__(self, archive_type=""): dirs = [Config.INSTANCE_HOME, "var", "scodoc", "archives"] if archive_type: diff --git a/app/scodoc/sco_bac.py b/app/scodoc/sco_bac.py index 64eb96e6..1bd08f1e 100644 --- a/app/scodoc/sco_bac.py +++ b/app/scodoc/sco_bac.py @@ -130,7 +130,7 @@ BACS_SSP = {(t[0], t[1]): t[2:] for t in _BACS} BACS_S = {t[0]: t[2:] for t in _BACS} -class Baccalaureat: +class Baccalaureat(object): def __init__(self, bac, specialite=""): self.bac = bac self.specialite = specialite diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index 8f0d2707..6e753915 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -97,7 +97,7 @@ def bulletin_get_class_name_displayed(context, formsemestre_id): return "invalide ! (voir paramètres)" -class BulletinGenerator: +class BulletinGenerator(object): "Virtual superclass for PDF bulletin generators" "" # Here some helper methods # see sco_bulletins_standard.BulletinGeneratorStandard subclass for real methods diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index ccf9a905..96dafd25 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -387,7 +387,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy) -class BulTableStyle: +class BulTableStyle(object): """Construction du style de tables reportlab platypus pour les bulletins "classiques" """ LINEWIDTH = 0.5 diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index aa114564..f81e5327 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -32,7 +32,7 @@ import time # Cache data -class simpleCache: +class simpleCache(object): def __init__(self): self.cache = {} self.inval_cache() # > diff --git a/app/scodoc/sco_codes_parcours.py b/app/scodoc/sco_codes_parcours.py index da948d0a..42010c19 100644 --- a/app/scodoc/sco_codes_parcours.py +++ b/app/scodoc/sco_codes_parcours.py @@ -171,7 +171,7 @@ DEVENIRS_NEXT2 = {NEXT_OR_NEXT2: 1, NEXT2: 1} NO_SEMESTRE_ID = -1 # code semestre si pas de semestres # Regles gestion parcours -class DUTRule: +class DUTRule(object): def __init__(self, rule_id, premise, conclusion): self.rule_id = rule_id self.premise = premise @@ -196,7 +196,7 @@ class DUTRule: DEFAULT_TYPE_PARCOURS = 100 # pour le menu de creation nouvelle formation -class TypeParcours: +class TypeParcours(object): TYPE_PARCOURS = None # id, utilisé par notes_formation.type_parcours NAME = None # required NB_SEM = 1 # Nombre de semestres @@ -213,7 +213,9 @@ class TypeParcours: UNUSED_CODES = set() # Ensemble des codes jury non autorisés dans ce parcours UE_IS_MODULE = False # 1 seul module par UE (si plusieurs modules, etudiants censéments inscrits à un seul d'entre eux) ECTS_ONLY = False # Parcours avec progression basée uniquement sur les ECTS - ALLOWED_UE_TYPES = list(UE_TYPE_NAME.keys()) # par defaut, autorise tous les types d'UE + ALLOWED_UE_TYPES = list( + UE_TYPE_NAME.keys() + ) # par defaut, autorise tous les types d'UE def check(self, formation=None): return True, "" # status, diagnostic_message diff --git a/app/scodoc/sco_core.py b/app/scodoc/sco_core.py index 97c848a3..75f8e195 100644 --- a/app/scodoc/sco_core.py +++ b/app/scodoc/sco_core.py @@ -35,7 +35,7 @@ def get_evaluations_cache(context): return CACHE_evaluations[u] -class CacheNotesTable: +class CacheNotesTable(object): """gestion rudimentaire de cache pour les NotesTables""" def __init__(self): @@ -191,7 +191,12 @@ class CacheNotesTable: if r: log( "get_bulletins_pdf(%s): cache hit %s (id=%s, thread=%s)" - % (version, formsemestre_id, id(self), six.moves._thread.get_ident()) + % ( + version, + formsemestre_id, + id(self), + six.moves._thread.get_ident(), + ) ) return r finally: diff --git a/app/scodoc/sco_etape_bilan.py b/app/scodoc/sco_etape_bilan.py index df9921e8..015b440d 100644 --- a/app/scodoc/sco_etape_bilan.py +++ b/app/scodoc/sco_etape_bilan.py @@ -125,7 +125,7 @@ FLAG = { } -class DataEtudiant: +class DataEtudiant(object): """ Structure de donnée des informations pour un étudiant """ @@ -230,7 +230,7 @@ def entete_liste_etudiant(): """ -class EtapeBilan: +class EtapeBilan(object): """ Structure de donnée représentation l'état global de la comparaison ScoDoc/Apogée """ diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index d42bb612..7abe00bb 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -576,7 +576,7 @@ admission_list = _admissionEditor.list admission_edit = _admissionEditor.edit # Edition simultanee de identite et admission -class EtudIdentEditor: +class EtudIdentEditor(object): def create(self, cnx, args, context=None, REQUEST=None): etudid = identite_create(cnx, args, context, REQUEST) args["etudid"] = etudid diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 3556efce..18605495 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -179,7 +179,7 @@ def Excel_MakeStyle( return style -class ScoExcelSheet: +class ScoExcelSheet(object): def __init__(self, sheet_name="feuille", default_style=None): self.sheet_name = sheet_name self.cells = [] # list of list diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index e1128765..fcfd857f 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -386,7 +386,7 @@ def _write_formsemestre_aux(context, sem, fieldname, valuename): # ------ Utilisé pour stocker le VDI avec le code étape (noms de fichiers maquettes et code semestres) -class ApoEtapeVDI: +class ApoEtapeVDI(object): _ETAPE_VDI_SEP = "!" def __init__(self, etape_vdi=None, etape="", vdi=""): diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 1048c5e1..70d505f6 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -1517,7 +1517,7 @@ def make_query_groups(group_ids): return "" -class GroupIdInferer: +class GroupIdInferer(object): """Sert à retrouver l'id d'un groupe dans un semestre donné à partir de son nom. Attention: il peut y avoir plusieurs groupes de même nom diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 2a9430e3..4a37cc0e 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -295,7 +295,7 @@ if (group_id) { return "\n".join(H) -class DisplayedGroupsInfos: +class DisplayedGroupsInfos(object): """Container with attributes describing groups to display in the page .groups_query_args : 'group_ids=xxx&group_ids=yyy' .base_url : url de la requete, avec les groupes, sans les autres paramètres diff --git a/app/scodoc/sco_news.py b/app/scodoc/sco_news.py index 88c98a95..cd462dd3 100644 --- a/app/scodoc/sco_news.py +++ b/app/scodoc/sco_news.py @@ -130,7 +130,7 @@ def scolar_news_summary(context, n=5): news = list(selected_news.values()) # sort by date, descending - news.sort(itemgetter("date"), reverse=True) + news.sort(key=itemgetter("date"), reverse=True) news = news[:n] # mimic EditableTable.list output formatting: for n in news: diff --git a/app/scodoc/sco_parcours_dut.py b/app/scodoc/sco_parcours_dut.py index ce7a48b1..2eaf52e0 100644 --- a/app/scodoc/sco_parcours_dut.py +++ b/app/scodoc/sco_parcours_dut.py @@ -63,7 +63,7 @@ from app.scodoc.dutrules import DUTRules # regles generees a partir du CSV from app.scodoc.sco_exceptions import ScoValueError -class DecisionSem: +class DecisionSem(object): "Decision prenable pour un semestre" def __init__( @@ -116,7 +116,7 @@ def SituationEtudParcours(context, etud, formsemestre_id): return SituationEtudParcoursGeneric(context, etud, formsemestre_id, nt) -class SituationEtudParcoursGeneric: +class SituationEtudParcoursGeneric(object): "Semestre dans un parcours" def __init__(self, context, etud, formsemestre_id, nt): diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py index 7ebc7d28..c415a776 100644 --- a/app/scodoc/sco_pdf.py +++ b/app/scodoc/sco_pdf.py @@ -334,7 +334,7 @@ def pdf_basic_page( import threading, time, six.moves.queue, six.moves._thread -class PDFLock: +class PDFLock(object): def __init__(self, timeout=15): self.Q = six.moves.queue.Queue(1) self.timeout = timeout diff --git a/app/scodoc/sco_permissions.py b/app/scodoc/sco_permissions.py index bc8a7864..a5419d4e 100644 --- a/app/scodoc/sco_permissions.py +++ b/app/scodoc/sco_permissions.py @@ -40,7 +40,7 @@ _SCO_PERMISSIONS = ( ) -class Permission: +class Permission(object): "Permissions for ScoDoc" NBITS = 1 # maximum bits used (for formatting) ALL_PERMISSIONS = [-1] diff --git a/app/scodoc/sco_portal_apogee.py b/app/scodoc/sco_portal_apogee.py index fd8ac01a..a7a737c0 100644 --- a/app/scodoc/sco_portal_apogee.py +++ b/app/scodoc/sco_portal_apogee.py @@ -50,7 +50,7 @@ def has_portal(context): return get_portal_url(context) -class PortalInterface: +class PortalInterface(object): def __init__(self): self.warning = False @@ -157,10 +157,14 @@ def get_inscrits_etape(context, code_etape, anneeapogee=None, ntrials=2): req = ( etud_url + "?" - + six.moves.urllib.parse.urlencode((("etape", code_etape), ("annee", anneeapogee))) + + six.moves.urllib.parse.urlencode( + (("etape", code_etape), ("annee", anneeapogee)) + ) ) else: - req = etud_url + "?" + six.moves.urllib.parse.urlencode((("etape", code_etape),)) + req = ( + etud_url + "?" + six.moves.urllib.parse.urlencode((("etape", code_etape),)) + ) actual_timeout = float(portal_timeout) / ntrials if portal_timeout > 0: actual_timeout = max(1, actual_timeout) @@ -565,7 +569,9 @@ def get_maquette_apogee(context, etape="", annee_scolaire=""): req = ( maquette_url + "?" - + six.moves.urllib.parse.urlencode((("etape", etape), ("annee", annee_scolaire))) + + six.moves.urllib.parse.urlencode( + (("etape", etape), ("annee", annee_scolaire)) + ) ) doc = scu.query_portal(req, timeout=portal_timeout) return doc diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py index 02a97da8..023fad4b 100644 --- a/app/scodoc/sco_report.py +++ b/app/scodoc/sco_report.py @@ -479,7 +479,7 @@ def table_suivi_cohorte( # 3-- Regroupe les semestres par date de debut P = [] # liste de periodsem - class periodsem: + class periodsem(object): pass # semestre de depart: diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py index 63321e0a..20be758c 100644 --- a/app/scodoc/sco_tag_module.py +++ b/app/scodoc/sco_tag_module.py @@ -59,7 +59,7 @@ from app.scodoc.sco_permissions import Permission # module_tag_set( module_id, taglist ) -> modifie les tags -class ScoTag: +class ScoTag(object): """Generic tags for ScoDoc""" # must be overloaded: diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 5f072725..bac16cdf 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -204,7 +204,7 @@ class DictDefault(dict): # obsolete, use collections.defaultdict return value -class WrapDict: +class WrapDict(object): """Wrap a dict so that getitem returns '' when values are None""" def __init__(self, adict, NoneValue=""): diff --git a/config/scodoc_config.py b/config/scodoc_config.py index 43618545..098b85c3 100644 --- a/config/scodoc_config.py +++ b/config/scodoc_config.py @@ -15,7 +15,7 @@ # souvent de comprendre le code qui les utilise pour ne pas faire d'erreur: attention. -class CFG: +class CFG(object): pass diff --git a/config/scodoc_config_tmpl.py b/config/scodoc_config_tmpl.py index 55cab115..00e5fc73 100644 --- a/config/scodoc_config_tmpl.py +++ b/config/scodoc_config_tmpl.py @@ -16,7 +16,7 @@ # souvent de comprendre le code qui les utilise pour ne pas faire d'erreur: attention. -class CFG: +class CFG(object): pass diff --git a/scodoc_manager.py b/scodoc_manager.py index 3bf8d4da..6c301b54 100644 --- a/scodoc_manager.py +++ b/scodoc_manager.py @@ -23,7 +23,12 @@ from config import Config from app.scodoc.sco_exceptions import ScoConfigurationError -class ScoDeptDescription: +class ScoDeptDescription(object): + """Description d'un département + .dept_id : eg "RT" + .db_uri : dept database URI + """ + def __init__(self, filename): """Read dept description from dept file""" if os.path.split(filename)[1][-4:] != ".cfg": diff --git a/scotests/sco_fake_gen.py b/scotests/sco_fake_gen.py index e312d310..b1bf273f 100644 --- a/scotests/sco_fake_gen.py +++ b/scotests/sco_fake_gen.py @@ -63,7 +63,7 @@ def logging_meth(func): return wrapper_logging_meth -class ScoFake: +class ScoFake(object): def __init__(self, context, verbose=True): self.context = context self.verbose = verbose