Moins de verbosité si pas de dates

This commit is contained in:
Yohann D'ANELLO 2021-05-02 15:47:01 +02:00
parent 92a3578b2b
commit 1b2fd576b7
1 changed files with 6 additions and 4 deletions

8
bot.py
View File

@ -146,6 +146,7 @@ def main(token: str) -> None:
me = Candidat(**api('me', token, user_id)['candidat']) me = Candidat(**api('me', token, user_id)['candidat'])
print(f'Salut {me.prenom} {me.nomNaissance} !') print(f'Salut {me.prenom} {me.nomNaissance} !')
print(f"Tu as accès aux places à {me.visibilityHour}.")
departements = [Departement(**dpt) for dpt in api('departements', token, user_id)['geoDepartementsInfos']] departements = [Departement(**dpt) for dpt in api('departements', token, user_id)['geoDepartementsInfos']]
@ -184,16 +185,17 @@ def main(token: str) -> None:
print("\n") print("\n")
for dpt in departements: for dpt in departements:
print(dpt.geoDepartement, dpt.count) print(dpt.geoDepartement, dpt.count, '(' + ', '.join(centre.nom for centre in dpt.centres) + ')')
for dpt in departements: for dpt in departements:
for centre in dpt.centres: for centre in dpt.centres:
dates = api(f"places?begin=2021-04-26T00:00:00.000&end=2021-07-31T23:59:59.999+02:00&geoDepartement={dpt.geoDepartement}&nomCentre={centre.nom}", token, user_id) dates = api(f"places?begin=2021-04-26T00:00:00.000&end=2021-07-31T23:59:59.999+02:00&geoDepartement={dpt.geoDepartement}&nomCentre={centre.nom}", token, user_id)
if dates:
send_mail(json.dumps(dates, indent=2), centre.nom) send_mail(json.dumps(dates, indent=2), centre.nom)
centre.dates = dates centre.dates = dates
PREFERRED_CENTRES = ["MASSY", "ANTONY", "RUNGIS", "MONTGERON", "CLAMART", "SAINT CLOUD", "EVRY", PREFERRED_CENTRES = ["MASSY", "ANTONY", "RUNGIS", "MONTGERON", "CLAMART", "SAINT CLOUD", "EVRY",
"VILLABE", "ETAMPES", "VELIZY VILLACOUBLAY", "MAISONS ALFORT", "TRAPPES", "SAINT PRIEST"] "VILLABE", "ETAMPES", "VELIZY VILLACOUBLAY", "MAISONS ALFORT", "TRAPPES"]
for name in PREFERRED_CENTRES: for name in PREFERRED_CENTRES:
for dpt in departements: for dpt in departements:
@ -204,7 +206,7 @@ def main(token: str) -> None:
continue continue
break break
for date in centre.dates: for date in centre.dates:
if name == "SAINT PRIEST" and ("T07:" in date or "T08:" in date): if name == "SAINT PRIEST" and ("T07:" in date or "T08:" in date or "T09:" in date or "T10:" in date):
continue continue
break break
else: else: