From 125eb245e9237623cfc2e153ff128b1663092701 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 5 Nov 2023 22:44:50 +0000 Subject: [PATCH] Make a start on adding subscriptions --- agenda/subscription.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 agenda/subscription.py diff --git a/agenda/subscription.py b/agenda/subscription.py new file mode 100644 index 0000000..9c2036c --- /dev/null +++ b/agenda/subscription.py @@ -0,0 +1,25 @@ +"""Subscriptions.""" + +import yaml + +from .types import Event + + +def get_events(filepath: str) -> list[Event]: + """Get subscription renewal dates.""" + events = [] + with open(filepath) as f: + items = yaml.safe_load(f) + + for item in items: + if "renewal_date" not in item: + continue + events.append( + Event( + date=item["renewal_date"], + name="subscription", + title=item["name"] + " renewal", + ) + ) + + return events