From 64442296946385e302db79fedaad751d65d33e17 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 30 Jan 2025 13:34:57 +0000 Subject: [PATCH] More validation --- validate_yaml.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/validate_yaml.py b/validate_yaml.py index 4e3ed1d..f656ea3 100755 --- a/validate_yaml.py +++ b/validate_yaml.py @@ -46,9 +46,17 @@ def check_flights(airlines: set[str]) -> None: """Check flights and ensure they are in chronological order.""" bookings = agenda.travel.parse_yaml("flights", data_dir) + flight_count = 0 + co2_flight_count = 0 + prev_first_depart = None for booking in bookings: + if "trip" not in booking: + pprint(booking) + assert "trip" in booking assert all(flight["airline"] in airlines for flight in booking["flights"]) + flight_count += len(booking["flights"]) + co2_flight_count += len([flight for flight in booking["flights"] if "co2_kg" in flight]) check_currency(booking) if prev_first_depart: @@ -57,7 +65,8 @@ def check_flights(airlines: set[str]) -> None: ), "Bookings are not in chronological order by first flight's departure." prev_first_depart = booking["flights"][0]["depart"] - print(len(bookings), "flights") + print(f"{len(bookings)} flight bookings, {flight_count} flights, " + f"{co2_flight_count} with CO2 numbers") def check_trains() -> None: