Validate accommodation YAML
This commit is contained in:
parent
20e8515bb7
commit
9f6ed9c372
2 changed files with 63 additions and 8 deletions
|
|
@ -5,6 +5,9 @@ import os
|
|||
import typing
|
||||
from datetime import date, timedelta
|
||||
|
||||
import yaml
|
||||
from rich.pretty import pprint
|
||||
|
||||
import agenda
|
||||
import agenda.conference
|
||||
import agenda.data
|
||||
|
|
@ -54,6 +57,38 @@ def check_events() -> None:
|
|||
print(len(events), "events")
|
||||
|
||||
|
||||
def check_accommodation() -> None:
|
||||
"""Check accommodation."""
|
||||
filepath = os.path.join(data_dir, "accommodation.yaml")
|
||||
accommodation_list = yaml.safe_load(open(filepath))
|
||||
|
||||
for stay in accommodation_list:
|
||||
try:
|
||||
assert all(
|
||||
field in stay
|
||||
for field in (
|
||||
"type",
|
||||
"name",
|
||||
"country",
|
||||
"location",
|
||||
"trip",
|
||||
"from",
|
||||
"to",
|
||||
)
|
||||
)
|
||||
if "latitude" in stay or "longitude" in stay:
|
||||
assert "latitude" in stay and "longitude" in stay
|
||||
assert all(
|
||||
isinstance(stay[key], (int, float))
|
||||
for key in ("latitude", "longitude")
|
||||
)
|
||||
except AssertionError:
|
||||
pprint(stay)
|
||||
raise
|
||||
|
||||
print(len(accommodation_list), "stays")
|
||||
|
||||
|
||||
def check_airports() -> None:
|
||||
"""Check airports."""
|
||||
airports = typing.cast(
|
||||
|
|
@ -89,6 +124,7 @@ def check() -> None:
|
|||
check_trains()
|
||||
check_conferences()
|
||||
check_events()
|
||||
check_accommodation()
|
||||
check_airports()
|
||||
check_stations()
|
||||
check_airlines()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue