Read YAML filepaths from config
This commit is contained in:
parent
a4b6a5a0ed
commit
3aeb2fe467
|
@ -303,12 +303,10 @@ def next_birthday(from_date: date, birth_date: date) -> tuple[date, int]:
|
|||
return next_birthday_date, age_at_next_birthday
|
||||
|
||||
|
||||
def get_birthdays(from_date: date, config: configparser.ConfigParser) -> list[Event]:
|
||||
def get_birthdays(from_date: date, filepath: str) -> list[Event]:
|
||||
"""Get birthdays from config."""
|
||||
filename = config["data"]["entities"]
|
||||
|
||||
events = []
|
||||
with open(filename) as f:
|
||||
with open(filepath) as f:
|
||||
entities = yaml.safe_load(f)
|
||||
|
||||
for entity in entities:
|
||||
|
@ -325,12 +323,10 @@ def get_birthdays(from_date: date, config: configparser.ConfigParser) -> list[Ev
|
|||
return events
|
||||
|
||||
|
||||
def get_travel(from_date: date, config: configparser.ConfigParser) -> list[Event]:
|
||||
def get_travel(from_date: date, filepath: str) -> list[Event]:
|
||||
"""Get birthdays from config."""
|
||||
filename = config["data"]["travel"]
|
||||
|
||||
events = []
|
||||
with open(filename) as f:
|
||||
with open(filepath) as f:
|
||||
items = yaml.safe_load(f)
|
||||
|
||||
for item in items:
|
||||
|
@ -414,9 +410,9 @@ def get_data(now: datetime) -> dict[str, str | object]:
|
|||
for key, value in xmas_last_posting_dates.items():
|
||||
events.append(Event(name=f"xmas_last_{key}", date=value))
|
||||
|
||||
events += get_birthdays(today, config)
|
||||
events += get_travel(today, config)
|
||||
events += get_conferences(today, "conferences.yaml")
|
||||
events += get_birthdays(today, config["data"]["entities"])
|
||||
events += get_travel(today, config["data"]["travel"])
|
||||
events += get_conferences(today, config["data"]["conferences"])
|
||||
events += waste_collection_events()
|
||||
|
||||
next_up_series = Event(
|
||||
|
|
Loading…
Reference in a new issue