From 5c5175111114d8ab55ced13188c9f8d1f0474c51 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 7 Nov 2023 16:56:47 +0100 Subject: [PATCH] Add missing code --- agenda/accommodation.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 agenda/accommodation.py diff --git a/agenda/accommodation.py b/agenda/accommodation.py new file mode 100644 index 0000000..08b4501 --- /dev/null +++ b/agenda/accommodation.py @@ -0,0 +1,24 @@ +"""Accomodation""" + +import yaml + +from .types import Event + + +def get_events(filepath: str) -> list[Event]: + """Get accomodation from YAML.""" + with open(filepath) as f: + return [ + Event( + date=item["from"], + end_date=item["to"], + name="accommodation", + title=( + f'{item["location"]} Airbnb' + if item["operator"] == "airbnb" + else item["name"] + ), + url=item.get("url"), + ) + for item in yaml.safe_load(f) + ]