Tue, 11 Sep 2018 21:02:25 +0300
update
72 | 1 | import buses |
2 | from configparser import ConfigParser | |
3 | profile = ConfigParser() | |
4 | profile.read('profiles/föli.ini') | |
5 | buses.load_buses('gtfs.zip', profile) | |
6 | ||
7 | def service_start_time(): | |
8 | from datetime import date, datetime, timedelta | |
9 | result = datetime.now().replace(hour = 0, minute = 0, second = 0, microsecond = 0) | |
10 | if datetime.now().hour < 4: | |
11 | result -= timedelta(1) | |
12 | return result | |
13 | ||
14 | def find_halt(data, stop_reference): | |
15 | from datetime import datetime | |
16 | info = (data['blockref'], datetime.fromtimestamp(data['originaimeddeparturetime']) - service_start_time()) | |
17 | trip = buses.trips_by_vehicle_info[info] | |
18 | return [halt for halt in buses.trips_by_vehicle_info[info].schedule if halt.stop.reference == stop_reference][0] |