From 5758d3f1d0ec19c162b416bd6deba6ac9801a16b Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 19 May 2024 13:33:04 +0200 Subject: [PATCH] Add more flags on trip list --- agenda/types.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/agenda/types.py b/agenda/types.py index 04c3970..1b4a27a 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -241,7 +241,13 @@ class Trip: ) if item["type"] == "train": for leg in item["legs"]: - name = f"{leg['from']} → {leg['to']}" + from_country = agenda.get_country(leg["from_station"]["country"]) + to_country = agenda.get_country(leg["to_station"]["country"]) + + assert from_country and to_country + from_flag = from_country.flag + to_flag = to_country.flag + name = f"{leg['from']} {from_flag} → {leg['to']} {to_flag}" elements.append( TripElement( when=leg["depart"], @@ -251,7 +257,14 @@ class Trip: ) ) if item["type"] == "ferry": - name = f"{item['from']} → {item['to']}" + from_country = agenda.get_country(item["from_terminal"]["country"]) + to_country = agenda.get_country(item["to_terminal"]["country"]) + + assert from_country and to_country + from_flag = from_country.flag + to_flag = to_country.flag + + name = f"{item['from']} {from_flag} → {item['to']} {to_flag}" elements.append( TripElement( when=item["depart"],