2024-03-11 15:58:56 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
"""Load YAML data to ensure validity."""
|
|
|
|
|
|
|
|
import os
|
2024-05-18 19:37:10 +01:00
|
|
|
import typing
|
2024-04-05 10:23:29 +01:00
|
|
|
from datetime import date, timedelta
|
2024-03-11 15:58:56 +00:00
|
|
|
|
2024-05-18 19:37:10 +01:00
|
|
|
import agenda
|
2024-03-11 15:58:56 +00:00
|
|
|
import agenda.conference
|
2024-04-05 10:23:29 +01:00
|
|
|
import agenda.data
|
2024-03-11 15:58:56 +00:00
|
|
|
import agenda.travel
|
|
|
|
import agenda.trip
|
2024-05-18 19:37:10 +01:00
|
|
|
import agenda.types
|
2024-03-11 15:58:56 +00:00
|
|
|
|
|
|
|
config = __import__("config.default", fromlist=[""])
|
|
|
|
|
|
|
|
data_dir = config.PERSONAL_DATA
|
|
|
|
|
|
|
|
trip_list = agenda.trip.build_trip_list(data_dir)
|
|
|
|
print(len(trip_list), "trips")
|
|
|
|
|
2024-04-05 10:21:41 +01:00
|
|
|
coords, routes = agenda.trip.get_coordinates_and_routes(trip_list, data_dir)
|
|
|
|
print(len(coords), "coords")
|
|
|
|
print(len(routes), "routes")
|
|
|
|
|
2024-03-11 15:58:56 +00:00
|
|
|
flights = agenda.travel.parse_yaml("flights", data_dir)
|
|
|
|
print(len(flights), "flights")
|
|
|
|
|
|
|
|
trains = agenda.travel.parse_yaml("trains", data_dir)
|
|
|
|
print(len(trains), "trains")
|
|
|
|
|
|
|
|
conferences = agenda.conference.get_list(os.path.join(data_dir, "conferences.yaml"))
|
|
|
|
print(len(conferences), "conferences")
|
2024-04-05 10:23:29 +01:00
|
|
|
|
|
|
|
today = date.today()
|
|
|
|
last_year = today - timedelta(days=365)
|
|
|
|
next_year = today + timedelta(days=2 * 365)
|
|
|
|
|
2024-05-18 11:04:28 +01:00
|
|
|
events = agenda.events_yaml.read(data_dir, last_year, next_year)
|
2024-04-05 10:23:29 +01:00
|
|
|
print(len(events), "events")
|
2024-05-18 19:37:10 +01:00
|
|
|
|
|
|
|
airports = typing.cast(
|
|
|
|
dict[str, agenda.types.StrDict], agenda.travel.parse_yaml("airports", data_dir)
|
|
|
|
)
|
|
|
|
print(len(airports), "airports")
|
|
|
|
for airport in airports.values():
|
|
|
|
assert "country" in airport
|
|
|
|
assert agenda.get_country(airport["country"])
|
|
|
|
|
|
|
|
|
|
|
|
stations = agenda.travel.parse_yaml("stations", data_dir)
|
|
|
|
print(len(stations), "stations")
|
|
|
|
for station in stations:
|
|
|
|
assert "country" in station
|
|
|
|
assert agenda.get_country(station["country"])
|