Remove line letter suffix

This commit is contained in:
Gabriel Augendre 2021-11-09 13:56:42 +01:00
parent a915581ba1
commit 4a2fa001c2

View file

@ -1,4 +1,5 @@
import enum import enum
import re
from typing import Any, DefaultDict, List, Optional from typing import Any, DefaultDict, List, Optional
import httpx import httpx
@ -48,7 +49,11 @@ async def stop(
passages = DefaultDict(list) passages = DefaultDict(list)
for passage in res.json().get("values"): for passage in res.json().get("values"):
if passage.get("id") == stop_id: if passage.get("id") == stop_id:
passages[passage.get("ligne")].append(passage.get("delaipassage")) ligne = passage.get("ligne")
ligne = re.sub(
"[A-Z]$", "", ligne
) # Remove letter suffix to group by commercial line name
passages[ligne].append(passage.get("delaipassage"))
passages_list = [] passages_list = []
for ligne, delais in passages.items(): for ligne, delais in passages.items():
passages_list.append(Passage(ligne=ligne, delais=delais)) passages_list.append(Passage(ligne=ligne, delais=delais))