aboutsummaryrefslogtreecommitdiff
path: root/data/vigo/download-stops.py
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-11-07 10:28:24 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-11-07 10:28:24 +0100
commit02525bcb98bc1841c5734623be4d7936e66f32b2 (patch)
treeb76fb21f6417b714fae564770c7cb7affe3843e7 /data/vigo/download-stops.py
parent37d8eedd641bb04c086797010292bcb25240d56d (diff)
Finish implementing navidad
Diffstat (limited to 'data/vigo/download-stops.py')
-rw-r--r--data/vigo/download-stops.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/data/vigo/download-stops.py b/data/vigo/download-stops.py
index f332f5b..3211f99 100644
--- a/data/vigo/download-stops.py
+++ b/data/vigo/download-stops.py
@@ -32,7 +32,7 @@ def apply_overrides(stops, overrides):
"""Apply overrides to the stop data and add new stops"""
# Track existing stop IDs
existing_stop_ids = {stop.get("stopId") for stop in stops}
-
+
# Apply overrides to existing stops
for stop in stops:
stop_id = stop.get("stopId")
@@ -67,18 +67,15 @@ def apply_overrides(stops, overrides):
if "cancelled" in override:
stop["cancelled"] = override["cancelled"]
- # Add alert title
+ if "alert" in override:
+ stop["alert"] = override["alert"]
+
if "title" in override:
stop["title"] = override["title"]
- # Add alert message
if "message" in override:
stop["message"] = override["message"]
- # Add alternate codes
- if "alternateCodes" in override:
- stop["alternateCodes"] = override["alternateCodes"]
-
# Add new stops (those with "new: true" parameter)
new_stops_added = 0
for stop_id, override in overrides.items():
@@ -86,7 +83,7 @@ def apply_overrides(stops, overrides):
if override.get("new") and stop_id not in existing_stop_ids:
# Ensure stop_id is an integer for consistency
stop_id_int = int(stop_id) if isinstance(stop_id, str) else stop_id
-
+
# Create the new stop
new_stop = {
"stopId": stop_id_int,
@@ -97,7 +94,7 @@ def apply_overrides(stops, overrides):
"longitude": override.get("location", {}).get("longitude"),
"lines": override.get("lines", [])
}
-
+
# Add optional fields (excluding the 'new' parameter)
if "alternateNames" in override:
for key, value in override["alternateNames"].items():
@@ -112,10 +109,10 @@ def apply_overrides(stops, overrides):
new_stop["message"] = override["message"]
if "alternateCodes" in override:
new_stop["alternateCodes"] = override["alternateCodes"]
-
+
stops.append(new_stop)
new_stops_added += 1
-
+
if new_stops_added > 0:
print(f"Added {new_stops_added} new stops from overrides")