From f624319c30888aed93ac2a5fea65796cec0309e7 Mon Sep 17 00:00:00 2001 From: Christopher Teutsch Date: Wed, 15 May 2019 21:42:37 +0200 Subject: [PATCH] Now sleeps until updates are probable --- monitor.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/monitor.py b/monitor.py index 0b228c6..07f0443 100644 --- a/monitor.py +++ b/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