diff --git a/agenda/__init__.py b/agenda/__init__.py index ee62425..c1aa70f 100644 --- a/agenda/__init__.py +++ b/agenda/__init__.py @@ -8,6 +8,7 @@ import warnings from datetime import date, datetime, timedelta, timezone from decimal import Decimal from time import time as unixtime +from typing import List import dateutil import dateutil.parser @@ -16,6 +17,7 @@ import holidays import pandas import pytz import requests +import yaml from dateutil.easter import easter from agenda import thespacedevs @@ -278,6 +280,28 @@ def get_us_holidays(input_date: date) -> list[Event]: ] +def get_conferences(input_date: date, filepath: str) -> List[Event]: + """Read conferences from a YAML file and return a list of Event objects.""" + with open(filepath, "r") as f: + data = yaml.safe_load(f) + + events = [] + for conf in data.get("conferences", []): + event_date = conf["start"] + + # Skip the conference if it is before the input date. + if event_date < input_date: + continue + event = Event( + name="conference", + date=event_date, + title=f'{conf["name"]} ({conf["location"]})', + ) + events.append(event) + + return events + + def next_birthday(from_date: date, birth_date: date) -> tuple[date, int]: """Calculate the date of the next birthday based on a given birth date.""" next_birthday_date = birth_date.replace(year=from_date.year) @@ -349,6 +373,7 @@ def get_data(now: datetime) -> dict[str, str | object]: events.append(Event(name=f"xmas_last_{key}", date=value)) events += get_birthdays(today, config) + events += get_conferences(today, "conferences.yaml") next_up_series = Event( date=date(2026, 6, 1),