Skip to content

Commit

Permalink
fix for diff route shortnames with same dest headsigns (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
anand-p-r committed Dec 2, 2020
1 parent c77a52f commit 07c6188
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
23 changes: 10 additions & 13 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,29 +152,26 @@ def parse_data(data, line_from_user = ""):

route_dict[DICT_KEY_ARRIVAL] = str(datetime.timedelta(seconds=arrival))
route_dict[DICT_KEY_DEST] = route.get("headsign", "")

route_dict[DICT_KEY_ROUTE] = ""
if route_dict[DICT_KEY_DEST] != "":
for bus in bus_lines:
patterns = bus.get("patterns", None)
line = bus.get("shortName", None)

if line is None:
continue

if patterns is None:
continue

for pattern in patterns:
headsign = pattern.get("headsign", None)

if headsign is not None:
dest_string = route_dict[DICT_KEY_DEST]
if headsign is not None and dest_string is not None:
if headsign.lower() in dest_string.lower():
# Check if the line and trip route names match for this
# schedule
trip = route.get("trip", "")
if trip != "":
trip_route = trip.get("route", "")
if trip_route != "":
trip_route_shortname = trip_route.get("shortName", "")
if trip_route_shortname != "":
if trip_route_shortname.lower() == line.lower():
route_dict[DICT_KEY_ROUTE] = line


routes.append(route_dict)

parsed_data[DICT_KEY_ROUTES] = routes
Expand Down
5 changes: 5 additions & 0 deletions const.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
realtimeState
serviceDay
headsign
trip {
route {
shortName
}
}
}
}
}
Expand Down

0 comments on commit 07c6188

Please sign in to comment.