infotbm/src/main.py

43 lines
1.2 KiB
Python
Raw Normal View History

2022-04-28 12:03:51 +02:00
import sys
2022-05-08 13:17:07 +02:00
from stop_area import *
from stop import *
from stop_route import StopRoute
2022-04-28 12:03:51 +02:00
from datetime import datetime
2022-04-30 01:43:20 +02:00
2022-04-28 12:03:51 +02:00
if __name__ == '__main__':
for word in sys.argv [1:]:
for area in get_stop_areas_by_name (word):
stop = get_stop_by_id (area.getId ())
for stopPoint in stop.getStopPoints ():
for route in stopPoint.getRoutes ():
if 'Tram' in route.getLineName ():
stopRoute = StopRoute (stopPoint.getId (), route.getId (), route.getLineId ())
line = stopRoute.get_line ()
for vehicule in line.get_vehicles ():
v = line.get_vehicle (vehicule)
if v.getRealtime ():
print (
str (v.getWaitTimeText ())
+ ' ('
+ datetime.fromtimestamp (v.getArrival ()).strftime (
'%H:%M'
)
+ ') → '
+ v.getDestination ()
+ ', Curr location: '
+ str (v.getLocation ())
)
else:
print (
'~'
+ str (v.getWaitTimeText ())
+ ' ('
+ datetime.fromtimestamp (v.getArrival ()).strftime (
'%H:%M'
)
+ ') → '
+ v.getDestination ()
+ ', Curr location: '
+ str (v.getLocation ())
)