Support trip updates with no stop time updates. Add more logging.

This commit is contained in:
Nahuel Lofeudo 2023-04-23 06:05:06 +01:00
parent 2570ab0cef
commit 2d00e744d6
1 changed files with 3 additions and 1 deletions

View File

@ -222,7 +222,7 @@ class GTFSClient():
trip_id = e.get("trip_update").get("trip").get("trip_id") trip_id = e.get("trip_update").get("trip").get("trip_id")
trip_action = e.get("trip_update").get("trip").get("schedule_relationship") trip_action = e.get("trip_update").get("trip").get("schedule_relationship")
if trip_action == "SCHEDULED": if trip_action == "SCHEDULED":
for u in e.get("trip_update").get("stop_time_update"): for u in e.get("trip_update", {}).get("stop_time_update", []):
delay = u.get("arrival", u.get("departure", {})).get("delay", 0) delay = u.get("arrival", u.get("departure", {})).get("delay", 0)
deltas_for_trip = (deltas.get(trip_id) or {}) deltas_for_trip = (deltas.get(trip_id) or {})
deltas_for_trip[u.get("stop_id")] = delay deltas_for_trip[u.get("stop_id")] = delay
@ -230,8 +230,10 @@ class GTFSClient():
elif trip_action == "ADDED": elif trip_action == "ADDED":
# TODO: Add support for added trips # TODO: Add support for added trips
print("Trip {} added.".format(trip_id))
pass pass
else: else:
print("Trip {} canceled.".format(trip_id))
canceled_trips.add(trip_id) canceled_trips.add(trip_id)
except Exception as x: except Exception as x:
print("Error parsing GTFS-R entry:", str(e)) print("Error parsing GTFS-R entry:", str(e))