parent
9f881d7177
commit
1397805450
1 changed files with 32 additions and 1 deletions
|
|
@ -385,9 +385,39 @@ def check_ferries() -> None:
|
|||
print(len(ferries), "ferries")
|
||||
|
||||
|
||||
def check_buses() -> None:
|
||||
"""Check buses and ensure no bus journey exceeds 12 hours."""
|
||||
buses = agenda.travel.parse_yaml("buses", data_dir)
|
||||
max_duration = timedelta(hours=12)
|
||||
|
||||
for bus in buses:
|
||||
depart = normalize_datetime(bus["depart"])
|
||||
arrive = normalize_datetime(bus["arrive"])
|
||||
|
||||
if arrive < depart:
|
||||
print("Invalid bus journey found (arrive before depart):")
|
||||
print(f" {bus.get('depart')} {bus.get('from', '')} -> {bus.get('to', '')}")
|
||||
print(f" arrive: {bus.get('arrive')}")
|
||||
assert False, "Bus journey arrival time is earlier than departure time."
|
||||
|
||||
duration = arrive - depart
|
||||
if duration > max_duration:
|
||||
print("Overlong bus journey found:")
|
||||
print(f" {bus.get('depart')} {bus.get('from', '')} -> {bus.get('to', '')}")
|
||||
print(f" arrive: {bus.get('arrive')}")
|
||||
print(f" duration: {duration}")
|
||||
assert False, "Bus journey is longer than 12 hours."
|
||||
|
||||
check_currency(bus)
|
||||
|
||||
print(len(buses), "buses")
|
||||
|
||||
|
||||
def check_airlines() -> list[agenda.types.StrDict]:
|
||||
"""Check airlines."""
|
||||
airlines = agenda.travel.parse_yaml("airlines", data_dir)
|
||||
airlines = typing.cast(
|
||||
list[agenda.types.StrDict], agenda.travel.parse_yaml("airlines", data_dir)
|
||||
)
|
||||
print(len(airlines), "airlines")
|
||||
for airline in airlines:
|
||||
try:
|
||||
|
|
@ -414,6 +444,7 @@ def check() -> None:
|
|||
check_flights({airline["iata"] for airline in airlines})
|
||||
check_trains()
|
||||
check_ferries()
|
||||
check_buses()
|
||||
check_conferences()
|
||||
check_events()
|
||||
check_accommodation()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue