Now sleeps until updates are probable
This commit is contained in:
parent
9001108904
commit
f624319c30
13
monitor.py
13
monitor.py
@ -127,17 +127,14 @@ def fixup_data(d: dict) -> dict:
|
||||
return d
|
||||
|
||||
|
||||
def fmt_trip(trip: dict) -> str:
|
||||
def print_trip(trip: dict) -> None:
|
||||
trip_part = "The {}:{} {} (???:{}: :{}) service to {} ".format(trip['hour'], trip['minute'], trip['lineNumber'], trip['lineCode'], trip['directionCode'], trip['direction'])
|
||||
if is_cancelled(trip):
|
||||
status_part = "is cancelled."
|
||||
print(trip_part + "is cancelled.")
|
||||
elif is_late(trip):
|
||||
status_part = "is {} minutes late.".format(trip['delay'])
|
||||
print(trip_part + "is {} minutes late.".format(trip['delay']))
|
||||
elif is_early(trip):
|
||||
status_part = "is {} minutes early.".format(-trip['delay'])
|
||||
else:
|
||||
status_part = "is on time."
|
||||
return trip_part + status_part
|
||||
print(trip_part + "is {} minutes early.".format(-trip['delay']))
|
||||
|
||||
|
||||
def get_next_refresh(data: dict):
|
||||
@ -163,7 +160,7 @@ def update():
|
||||
)
|
||||
reply_data = fixup_data(reply_data)
|
||||
for trip in reply_data['departureData']:
|
||||
print(fmt_trip(trip))
|
||||
print_trip(trip)
|
||||
return reply_data
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user