diff --git a/agenda/data.py b/agenda/data.py index 7789d0c..99c0bbd 100644 --- a/agenda/data.py +++ b/agenda/data.py @@ -11,6 +11,7 @@ import dateutil.tz import holidays import lxml import pytz +import yaml from dateutil.relativedelta import FR, relativedelta from . import ( @@ -147,6 +148,7 @@ async def bristol_waste_collection_events( def combine_holidays(events: list[Event]) -> list[Event]: + """Combine UK and US holidays with the same date and title.""" combined: dict[tuple[date, str], Event] = {} for e in events: @@ -161,15 +163,16 @@ def combine_holidays(events: list[Event]) -> list[Event]: return list(combined.values()) -def xmas_last_posting(config: configparser.ConfigParser) -> list[Event]: - """Last posting days for Christmas.""" +def read_events_yaml(data_dir: str) -> list[Event]: + """Read eventes from YAML file.""" return [ Event( - name=f"xmas_last_{key}", - date=date.fromisoformat(config["xmas_last_posting_dates"][key]), - url="https://www.postoffice.co.uk/last-posting-dates", + name=item["name"], + date=item["end_date" if item["name"] == "travel_insurance" else "date"], + title=item.get("title"), + url=item.get("url"), ) - for key in ("first", "second") + for item in yaml.safe_load(open(os.path.join(data_dir, "events.yaml"))) ] @@ -259,17 +262,10 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]: events += travel.all_events(config["data"]["personal-data"]) events += conference.get_list(os.path.join(my_data, "conferences.yaml")) events += backwell_bins + bristol_bins - events += xmas_last_posting(config) + events += read_events_yaml(my_data) events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml")) - next_up_series = Event( - date=date(2026, 6, 1), - title="70 Up", - name="next_up_series", - ) - events.append(next_up_series) - events.sort(key=operator.attrgetter("as_datetime")) reply["events"] = events diff --git a/templates/index.html b/templates/index.html index 13a7e1c..77fdedb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -66,8 +66,7 @@ "next_us_presidential_election": "US pres. election", "xmas_last_second": "Christmas last posting 2nd class", "xmas_last_first": "Christmas last posting 1st class", - "xmas_day": "Christmas day", - "next_up_series": "Next Up documentary", + "up_series": "Up documentary", "waste_schedule": "Waste schedule", "gwr_advance_tickets": "GWR advance tickets", "critical_mass": "Critical Mass",