agenda/validate_yaml.py

38 lines
1,001 B
Python
Executable file

#!/usr/bin/python3
"""Load YAML data to ensure validity."""
import os
from datetime import date, timedelta
import agenda.conference
import agenda.data
import agenda.travel
import agenda.trip
config = __import__("config.default", fromlist=[""])
data_dir = config.PERSONAL_DATA
trip_list = agenda.trip.build_trip_list(data_dir)
print(len(trip_list), "trips")
coords, routes = agenda.trip.get_coordinates_and_routes(trip_list, data_dir)
print(len(coords), "coords")
print(len(routes), "routes")
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")
today = date.today()
last_year = today - timedelta(days=365)
next_year = today + timedelta(days=2 * 365)
events = agenda.data.read_events_yaml(data_dir, last_year, next_year)
print(len(events), "events")