Compare commits

...

2 Commits

Author SHA1 Message Date
Sasha MOREL 74fff341be Ne plus retourner les arrêts vides 2021-09-18 09:28:11 +02:00
Sasha MOREL 0a2fc7e596 Simplification de la traduction de lignes
J'ai aussi ajouté les Bat³ et les Citéis.
2021-09-18 09:26:10 +02:00
1 changed files with 25 additions and 14 deletions

39
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,23 +102,25 @@ def show_stops_from_ref (ref):
'terminus': j ['name'], 'terminus': j ['name'],
'line_human': j ['line'] ['name'], 'line_human': j ['line'] ['name'],
} }
try: add = False
line_id = search ('[0-9A-D]+$', rte ['line_human']).group () if rte ['line_human'] in line_translate:
except AttributeError: line_id = line_translate [rte ['line_human']]
continue add = True
try: else:
try:
line_id = search ('[0-9]+$', rte ['line_human']).group ()
except AttributeError:
continue
line_id = '%02d' % int (line_id) line_id = '%02d' % int (line_id)
except ValueError: for i in line_types:
pass if rte ['line_human'] [0:len (i)] == i:
a = False add = True
for i in line_types: break
if rte ['line_human'] [0:len (i)] == i: if add:
a = True
break
if a:
rte ['line_id'] = line_id rte ['line_id'] = line_id
s ['routes'].append (rte) s ['routes'].append (rte)
r ['stop_points'].append (s) if s ['routes'] != []:
r ['stop_points'].append (s)
return (r) return (r)