Compare commits

..

No commits in common. "aafd37ab5ac915261c84a0bbc015d96d78685f6b" and "aceee6ac4db77f472913c299883b610248d8996f" have entirely different histories.

2 changed files with 6 additions and 12 deletions

1
.gitignore vendored
View file

@ -3,4 +3,3 @@ __pycache__/
__pycache__ __pycache__
.mypy_cache .mypy_cache
config config
.hypothesis/

View file

@ -11,7 +11,6 @@ from typing import List
import dateutil import dateutil
import dateutil.parser import dateutil.parser
import dateutil.tz
import exchange_calendars import exchange_calendars
import holidays import holidays
import lxml import lxml
@ -305,20 +304,16 @@ def next_birthday(from_date: date, birth_date: date) -> tuple[date, int]:
def get_birthdays(from_date: date, config: configparser.ConfigParser) -> list[Event]: def get_birthdays(from_date: date, config: configparser.ConfigParser) -> list[Event]:
"""Get birthdays from config.""" """Get birthdays from config."""
filename = config["data"]["entities"] if "birthdays" not in config:
return []
events = [] events = []
with open(filename) as f: for name, date_str in config["birthdays"].items():
entities = yaml.safe_load(f) bday = next_birthday(from_date, datetime.strptime(date_str, "%Y-%m-%d").date())
for entity in entities:
birthday = date(**entity["birthday"])
bday, age = next_birthday(from_date, birthday)
events.append( events.append(
Event( Event(
date=bday, date=bday[0],
name="birthday", name="birthday",
title=f'{entity["label"]} (aged {age})', title=f"{name.title()} (aged {bday[1]})",
) )
) )