service.py

changeset 55
0f1d046b3f78
parent 53
1c934953c3e6
child 61
0c9b09f694f3
--- a/service.py	Thu Aug 31 21:30:34 2017 +0300
+++ b/service.py	Sun Sep 03 14:10:38 2017 +0300
@@ -10,6 +10,7 @@
 import buses
 
 app = Flask(__name__)
+suffix_regions = {'naantalin pikatie', 'helsingin valtatie'}
 
 # Varmista ettei järjestelmän kieliasetukset sotke muotoiluja
 def reset_locale():
@@ -65,8 +66,8 @@
 	trip_length = schedule_entry['trip'].length - schedule_entry['stop'].traveled_distance
 	sign = reduce_schedule(schedule_entry['trip'].concise_schedule(schedule_entry['stop']), trip_length = trip_length)
 	if sign:
-		sign = [tr(place, 'paikat') for place in sign]
-		sign_representation = ' - '.join(sign)
+		sign_representation = ' - '.join(tr(place, 'paikat') for place in sign if place not in suffix_regions)
+		sign_representation += ''.join(' ' + tr(place, 'suffix-places') for place in sign if place in suffix_regions)
 		#if len(sign_representation) > 25:
 		#	k = ceil(len(sign) / 2)
 		#	sign_representation = ' - '.join(sign[:k]) + '\n' + ' - '.join(sign[k:])

mercurial