From e814e1b1359c0111f214e5241873e795c08f16c4 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 2 Jul 2024 14:46:51 +0300 Subject: [PATCH] Adjust airline YAML format to allow more fields --- agenda/trip.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agenda/trip.py b/agenda/trip.py index cbb72fc..b0c50cf 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -93,6 +93,7 @@ def load_flight_bookings(data_dir: str) -> list[StrDict]: """Load flight bookings.""" bookings = load_travel("flight", "flights", data_dir) airlines = yaml.safe_load(open(os.path.join(data_dir, "airlines.yaml"))) + iata = {a["iata"]: a["name"] for a in airlines} airports = travel.parse_yaml("airports", data_dir) for booking in bookings: for flight in booking["flights"]: @@ -101,7 +102,7 @@ def load_flight_bookings(data_dir: str) -> list[StrDict]: if flight["to"] in airports: flight["to_airport"] = airports[flight["to"]] if "airline" in flight: - flight["airline_name"] = airlines.get(flight["airline"], "[unknown]") + flight["airline_name"] = iata.get(flight["airline"], "[unknown]") flight["distance"] = travel.flight_distance(flight) return bookings