Skip to content

Commit

Permalink
Refactor stops_for_location.py for improved readability and maintaina…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
Ahmedhossamdev committed Aug 1, 2024
1 parent 0edb289 commit 4170e67
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/stops_for_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from onebusaway import OnebusawaySDK

# Load settings from .en`v file, if it exists. If not, we'll use the
# Load settings from .env file, if it exists. If not, we'll use the
# Puget Sound server URL (which is also the default in the SDK) and
# the 'TEST' API key.
settings = load_settings(
Expand All @@ -27,8 +27,8 @@

# make it easy to look up routes by ID.
reference_map = {}
for route in references.routes:
reference_map[route.id] = route
for ref_route in references.routes:
reference_map[ref_route.id] = ref_route

for stop in stops:
print(f"{stop.name} ({stop.lat}, {stop.lon})")
Expand All @@ -39,7 +39,7 @@
route: Any = reference_map[route_id]

# Get a string that looks like "D Line - Blue Ridge/Crown Hill - Ballard - Downtown Seattle"
description = [route.null_safe_short_name, route.description]
description = [e for e in description if e]
description = " - ".join(description)
print(f" {description}")
description_list = [route.null_safe_short_name, route.description]
description_list = [e for e in description_list if e]
description_str = " - ".join(description_list)
print(f" {description_str}")

0 comments on commit 4170e67

Please sign in to comment.