Simplification de la traduction de lignes

J'ai aussi ajouté les Bat³ et les Citéis.
This commit is contained in:
Sasha MOREL 2021-09-18 09:26:10 +02:00
parent 2df827d3ad
commit 0a2fc7e596
1 changed files with 23 additions and 13 deletions

24
stop.py
View File

@ -17,7 +17,16 @@ line_types = (
'Lianes', 'Lianes',
'Ligne', 'Ligne',
'Bus Relais', 'Bus Relais',
'Citéis',
) )
line_translate = {
'Tram A': 'A',
'Tram B': 'B',
'Tram C': 'C',
'Tram D': 'D',
'TBNight': '58',
'BAT3': '69',
}
def search_stop_by_name (keyword): def search_stop_by_name (keyword):
@ -93,20 +102,21 @@ def show_stops_from_ref (ref):
'terminus': j ['name'], 'terminus': j ['name'],
'line_human': j ['line'] ['name'], 'line_human': j ['line'] ['name'],
} }
add = False
if rte ['line_human'] in line_translate:
line_id = line_translate [rte ['line_human']]
add = True
else:
try: try:
line_id = search ('[0-9A-D]+$', rte ['line_human']).group () line_id = search ('[0-9]+$', rte ['line_human']).group ()
except AttributeError: except AttributeError:
continue continue
try:
line_id = '%02d' % int (line_id) line_id = '%02d' % int (line_id)
except ValueError:
pass
a = False
for i in line_types: for i in line_types:
if rte ['line_human'] [0:len (i)] == i: if rte ['line_human'] [0:len (i)] == i:
a = True add = True
break break
if a: if add:
rte ['line_id'] = line_id rte ['line_id'] = line_id
s ['routes'].append (rte) s ['routes'].append (rte)
r ['stop_points'].append (s) r ['stop_points'].append (s)