code cleaning

This commit is contained in:
Emmanuel Viennet 2022-09-30 16:01:43 +02:00
parent 9527240ea8
commit d6be0e131f

View File

@ -63,10 +63,10 @@ def formsemestre_get_ics_url(sem):
ics_url = ics_url_tmpl.format(sem=sem) ics_url = ics_url_tmpl.format(sem=sem)
except: except:
log( log(
"Exception in formsemestre_get_ics_url(formsemestre_id=%s)" f"""Exception in formsemestre_get_ics_url(formsemestre_id={sem["formsemestre_id"]})
% sem["formsemestre_id"] ics_url_tmpl='{ics_url_tmpl}'
"""
) )
log("ics_url_tmpl='%s'" % ics_url_tmpl)
log(traceback.format_exc()) log(traceback.format_exc())
return None return None
return ics_url return ics_url
@ -79,10 +79,9 @@ def formsemestre_load_ics(sem):
if not ics_url: if not ics_url:
ics_data = "" ics_data = ""
else: else:
log("Loading edt from %s" % ics_url) log(f"Loading edt from {ics_url}")
f = urllib.request.urlopen( # 5s TODO: add config parameter, eg for slow networks
ics_url, timeout=5 f = urllib.request.urlopen(ics_url, timeout=5)
) # 5s TODO: add config parameter, eg for slow networks
ics_data = f.read() ics_data = f.read()
f.close() f.close()
@ -90,12 +89,6 @@ def formsemestre_load_ics(sem):
return cal return cal
# def formsemestre_edt_groups_used(sem):
# """L'ensemble des groupes EDT utilisés dans l'emploi du temps publié"""
# cal = formsemestre_load_ics(sem)
# return {e["X-GROUP-ID"].decode("utf8") for e in events}
def get_edt_transcodage_groups(formsemestre_id): def get_edt_transcodage_groups(formsemestre_id):
"""-> { nom_groupe_edt : nom_groupe_scodoc }""" """-> { nom_groupe_edt : nom_groupe_scodoc }"""
# TODO: valider ces données au moment où on enregistre les préférences # TODO: valider ces données au moment où on enregistre les préférences
@ -116,10 +109,10 @@ def get_edt_transcodage_groups(formsemestre_id):
edt2sco[fs[0]] = fs[1] edt2sco[fs[0]] = fs[1]
sco2edt[fs[1]] = fs[0] sco2edt[fs[1]] = fs[0]
else: else:
msg = "ligne %s invalide" % line_num msg = f"ligne {line_num} invalide"
line_num += 1 line_num += 1
log("sco2edt=%s" % pprint.pformat(sco2edt)) log(f"sco2edt={pprint.pformat(sco2edt)}")
return edt2sco, sco2edt, msg return edt2sco, sco2edt, msg
@ -152,13 +145,6 @@ def group_edt_json(group_id, start="", end=""): # actuellement inutilisé
return scu.sendJSON(J) return scu.sendJSON(J)
"""XXX
for e in events:
if 'DESCRIPTION' in e:
print e.decoded('DESCRIPTION')
"""
def experimental_calendar(group_id=None, formsemestre_id=None): # inutilisé def experimental_calendar(group_id=None, formsemestre_id=None): # inutilisé
"""experimental page""" """experimental page"""
return "\n".join( return "\n".join(