diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..b7f214681 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] + max-line-length = 88 + ignore = E203,W503 \ No newline at end of file diff --git a/app/comp/moy_sem.py b/app/comp/moy_sem.py index a1fe0104a..15313550a 100644 --- a/app/comp/moy_sem.py +++ b/app/comp/moy_sem.py @@ -78,7 +78,11 @@ def compute_sem_moys_apc_using_ects( else: ects = ects_df.to_numpy() # ects est maintenant un array nb_etuds x nb_ues + moy_gen = (etud_moy_ue_df * ects).sum(axis=1) / ects.sum(axis=1) + except ZeroDivisionError: + # peut arriver si aucun module... on ignore + moy_gen = pd.Series(np.NaN, index=etud_moy_ue_df.index) except TypeError: if None in ects: formation = db.session.get(Formation, formation_id) diff --git a/app/email.py b/app/email.py index a75b2def3..a983ef2df 100644 --- a/app/email.py +++ b/app/email.py @@ -79,13 +79,15 @@ Adresses d'origine: to : {orig_to} cc : {orig_cc} bcc: {orig_bcc} ---- +--- \n\n""" + msg.body ) current_app.logger.info( - f"""email sent to{' (mode test)' if email_test_mode_address else ''}: {msg.recipients} + f"""email sent to{ + ' (mode test)' if email_test_mode_address else '' + }: {msg.recipients} from sender {msg.sender} """ ) @@ -98,7 +100,8 @@ def get_from_addr(dept_acronym: str = None): """L'adresse "from" à utiliser pour envoyer un mail Si le departement est spécifié, ou si l'attribut `g.scodoc_dept`existe, - prend le `email_from_addr` des préférences de ce département si ce champ est non vide. + prend le `email_from_addr` des préférences de ce département si ce champ + est non vide. Sinon, utilise le paramètre global `email_from_addr`. Sinon, la variable de config `SCODOC_MAIL_FROM`. """ diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index 3b7dd2654..044d0dc61 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -1,19 +1,17 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- +import datetime import html import traceback + +from flask import g, current_app, abort import psycopg2 import psycopg2.pool import psycopg2.extras -from flask import g, current_app, abort - -import app -import app.scodoc.sco_utils as scu from app import log from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError -import datetime quote_html = html.escape diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 1e56ca87e..8a04cac27 100755 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -318,7 +318,7 @@ def list_abs_in_range( Returns: List of absences """ - if matin != None: + if matin is not None: matin = _toboolean(matin) ismatin = " AND A.MATIN = %(matin)s " else: @@ -387,7 +387,7 @@ def count_abs_just(etudid, debut, fin, matin=None, moduleimpl_id=None) -> int: Returns: An integer. """ - if matin != None: + if matin is not None: matin = _toboolean(matin) ismatin = " AND A.MATIN = %(matin)s " else: @@ -482,7 +482,9 @@ def _get_abs_description(a, cursor=None): else: a["matin"] = False cursor.execute( - """select * from absences where etudid=%(etudid)s and jour=%(jour)s and matin=%(matin)s order by entry_date desc""", + """SELECT * FROM absences + WHERE etudid=%(etudid)s AND jour=%(jour)s AND matin=%(matin)s + ORDER BY entry_date desc""", a, ) A = cursor.dictfetchall() @@ -517,9 +519,9 @@ def list_abs_jour(date, am=True, pm=True, is_abs=True, is_just=None): req = """SELECT DISTINCT etudid, jour, matin FROM ABSENCES A WHERE A.jour = %(date)s """ - if is_abs != None: + if is_abs is not None: req += " AND A.estabs = %(is_abs)s" - if is_just != None: + if is_just is not None: req += " AND A.estjust = %(is_just)s" if not am: req += " AND NOT matin " @@ -883,7 +885,7 @@ def MonthTableBody( descr = ev[4] # cc = [] - if color != None: + if color is not None: cc.append('
Ajout de {nbadded} absences {just_str}justifiées + f"""
Ajout de {nbadded} absences {just_str}justifiées du {datedebut} au {datefin} {indication_module}
""" ) else: H.append( - f"""Aucune date ouvrable + f"""
Aucune date ouvrable entre le {datedebut} et le {datefin} !
""" @@ -152,11 +152,11 @@ def doSignaleAbsence( H.append( f"""Module: +
Module: