From 284885c2213cef5398f01c0c06db6a124f64ad66 Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Sun, 29 Dec 2024 07:05:07 -0700 Subject: [PATCH] moved processing from main to process_year --- main.py | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/main.py b/main.py index bd7ec73..9a22bca 100755 --- a/main.py +++ b/main.py @@ -120,34 +120,33 @@ def write_calendar(events: list[Event]) -> None: writer.map("event_description").to("EVENT DESCRIPTION") writer.write() + +def process_year(MONTHS, monthly_events): + """process full year and return list of events""" + events = [] + for month in range(1, 13): + print(f"MONTH: {month}") + for week_of_month, week in enumerate(MONTHS[month]): + print(week_of_month, week) + for day_of_week, day in enumerate(week): + if day > 0: + """ + month, week_of_month, day_of_week, day + use monthly_events[day_of_week] + """ + print(f" {day_of_week}-{day:02d}", end=" ") + day_events = [x[1:] for x in monthly_events[day_of_week] if week_of_month + 1 in x[0]] + print(day_events) + print() + + return events + @click.command() def main(): """create csv file""" - events: list[Event] = [] - for month, weeks in MONTHS.items(): - add_tuesdays(events, YEAR, month, weeks) - add_wednesdays(events, YEAR, month, weeks) - add_thursdays(events, YEAR, month, weeks) - add_fridays(events, YEAR, month, weeks) - add_saturdays(events, YEAR, month, weeks) - add_sundays(events, YEAR, month, weeks) - - """ - month = 1 - for week_of_month, week in enumerate(MONTHS[month]): - print(week_of_month, week) - for day_of_week, day in enumerate(week): - if day > 0: - """ - month, week_of_month, day_of_week, day - use monthly_events[day_of_week] - """ - print(f" {day_of_week}-{day:02d}", end=" ") - day_events = [x[1:] for x in monthly_events[day_of_week] if week_of_month + 1 in x[0]] - print(day_events) - print() - # events = sort_events(events) - # write_calendar(events) + events = process_year(MONTHS, monthly_events) + events = sort_events(events) + write_calendar(events) sys.exit(0)