From 78add09990caf33c38ffc1dfb62a1a9d53ffb82d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 23 Aug 2023 01:42:03 +0200 Subject: [PATCH] flake8 config. Code cosmetic. --- .flake8 | 3 + app/email.py | 9 +- app/scodoc/sco_abs.py | 23 +++--- app/scodoc/sco_abs_views.py | 137 +++++++++++++++++++------------ app/scodoc/sco_assiduites.py | 11 +-- app/scodoc/sco_bulletins_json.py | 2 +- 6 files changed, 113 insertions(+), 72 deletions(-) create mode 100644 .flake8 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/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/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('' % color) else: cc.append('') @@ -896,7 +898,7 @@ def MonthTableBody( cc.append("" % (href, descr)) if legend or d == 1: - if pad_width != None: + if pad_width is not None: n = pad_width - len(legend) # pad to 8 cars if n > 0: legend = ( @@ -959,7 +961,7 @@ def MonthTableBody( ev_year = int(ev[0][:4]) ev_month = int(ev[0][5:7]) ev_day = int(ev[0][8:10]) - if ev[4] != None: + if ev[4] is not None: ev_half = int(ev[4]) else: ev_half = 0 @@ -978,7 +980,7 @@ def MonthTableBody( if len(ev) > 5 and ev[5]: descr = ev[5] # - if color != None: + if color is not None: cc.append('' % (color)) else: cc.append('') @@ -1072,7 +1074,8 @@ def invalidate_abs_count_sem(sem): def invalidate_abs_etud_date(etudid, date): # was invalidateAbsEtudDate - """Doit etre appelé à chaque modification des absences pour cet étudiant et cette date. + """Doit etre appelé à chaque modification des absences + pour cet étudiant et cette date. Invalide cache absence et caches semestre date: date au format ISO """ diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index f3473bf5d..4af828c39 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -137,14 +137,14 @@ def doSignaleAbsence( ] if dates: H.append( - f"""

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