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__
.mypy_cache
config
.hypothesis/

View file

@ -11,7 +11,6 @@ from typing import List
import dateutil
import dateutil.parser
import dateutil.tz
import exchange_calendars
import holidays
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]:
"""Get birthdays from config."""
filename = config["data"]["entities"]
if "birthdays" not in config:
return []
events = []
with open(filename) as f:
entities = yaml.safe_load(f)
for entity in entities:
birthday = date(**entity["birthday"])
bday, age = next_birthday(from_date, birthday)
for name, date_str in config["birthdays"].items():
bday = next_birthday(from_date, datetime.strptime(date_str, "%Y-%m-%d").date())
events.append(
Event(
date=bday,
date=bday[0],
name="birthday",
title=f'{entity["label"]} (aged {age})',
title=f"{name.title()} (aged {bday[1]})",
)
)