add exact match notice on stations helper function

This commit is contained in:
Kaaninchen
2026-08-18 18:47:51 +02:00
parent bd506ff9da
commit 7a3902b7d3
+9 -7
View File
@@ -21,10 +21,9 @@ headers = {
endpoint = "https://api.transitous.org" endpoint = "https://api.transitous.org"
def check_stations(): def check_stations():
logger(f"Testing {len(station_names)} stations...")
all_stations_output = {} all_stations_output = {}
minimal_overview = { minimal_overview = {}
"stations": {}
}
for station in station_names: for station in station_names:
req = f"{endpoint}/api/v1/geocode" req = f"{endpoint}/api/v1/geocode"
@@ -54,17 +53,16 @@ def check_stations():
"tz": entry.get("tz"), "tz": entry.get("tz"),
"country": entry.get("country"), "country": entry.get("country"),
"coords": coords, "coords": coords,
"modes": modes,
"id": station_id, "id": station_id,
"modes": modes,
} }
if stop_name: if stop_name:
stops_dict[stop_name] = stop_details stops_dict[stop_name] = stop_details
aliases_list.append(stop_name) aliases_list.append(stop_name)
if stop_name == station: if stop_name == station:
if not exact_match: if not exact_match:
logger(f"Exact match found! {station} is an assigned station! Bot would use that station directly")
exact_match = True exact_match = True
if not stops_dict: if not stops_dict:
@@ -72,10 +70,14 @@ def check_stations():
continue continue
all_stations_output[station] = { all_stations_output[station] = {
"exact_match": exact_match,
"associated": stops_dict "associated": stops_dict
} }
minimal_overview["stations"][station] = aliases_list minimal_overview[station] = {
"exact_match": exact_match,
"names": aliases_list
}
logger(json.dumps(minimal_overview, indent=4, ensure_ascii=False)) logger(json.dumps(minimal_overview, indent=4, ensure_ascii=False))