service.py

changeset 93
53ee9e945673
parent 92
16a5c37e4e67
child 94
e27c18f080d1
equal deleted inserted replaced
92:16a5c37e4e67 93:53ee9e945673
212 region = hasattr(bus_stop, 'region_name') and bus_stop.region or None, 212 region = hasattr(bus_stop, 'region_name') and bus_stop.region or None,
213 location = bus_stop.location, 213 location = bus_stop.location,
214 cluster = bus_stop.cluster.url_name if len(bus_stop.cluster.stops) > 1 else None, 214 cluster = bus_stop.cluster.url_name if len(bus_stop.cluster.stops) > 1 else None,
215 tr = tr, 215 tr = tr,
216 typename = bus_stop.typename, 216 typename = bus_stop.typename,
217 service = min(bus_stop.services),
217 ) 218 )
218 219
219 def week_schedule(bus_stop, **kwargs): 220 def week_schedule(bus_stop, **kwargs):
220 for i in range(-1, 7): 221 for i in range(-1, 7):
221 try: 222 try:
606 link_to_map = cluster.center.link_to_map, 607 link_to_map = cluster.center.link_to_map,
607 location = cluster.center, 608 location = cluster.center,
608 stops_in_cluster = stops_in_cluster, 609 stops_in_cluster = stops_in_cluster,
609 amount_of_stops_in_cluster = len(stops_in_cluster), 610 amount_of_stops_in_cluster = len(stops_in_cluster),
610 tr = tr, 611 tr = tr,
612 service = min(set.union(*[bus_stop.services for bus_stop in cluster.stops])),
611 ) 613 )
612 614
613 def day_class(weekday): 615 def day_class(weekday):
614 if weekday < 5: 616 if weekday < 5:
615 return 'working-day' 617 return 'working-day'
756 route = trip.route.reference, 758 route = trip.route.reference,
757 description = ' - '.join(tr(place, 'region_name') for place in sign), 759 description = ' - '.join(tr(place, 'region_name') for place in sign),
758 night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), 760 night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time),
759 tr = tr, 761 tr = tr,
760 length = trip.length / 1000, 762 length = trip.length / 1000,
763 service = trip.route.service,
761 ) 764 )
762 765
763 @app.route('/route/<name>') 766 @app.route('/route/<name>')
764 def route_page(name): 767 def route_page(name):
765 from buses import routes 768 from buses import routes
814 from regions import parse_regions 817 from regions import parse_regions
815 regions = parse_regions(profile['regions']['osm-path']) 818 regions = parse_regions(profile['regions']['osm-path'])
816 tr.load_regions(regions) 819 tr.load_regions(regions)
817 import busroute 820 import busroute
818 busroute.regions = regions 821 busroute.regions = regions
819 buses.load_buses(args.gtfs_zip_path, regions = regions) 822 buses.load_buses(args.gtfs_zip_path)
820 823
821 if __name__ == '__main__': 824 if __name__ == '__main__':
822 app.run(debug = args.debug, port = args.port) 825 app.run(debug = args.debug, port = args.port)

mercurial