Adjust airline YAML format to allow more fields
This commit is contained in:
parent
1e39e75117
commit
e814e1b135
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue