moved processing into months and month
This commit is contained in:
parent
284885c221
commit
037981040a
34
main.py
34
main.py
@ -121,30 +121,36 @@ def write_calendar(events: list[Event]) -> None:
|
||||
writer.write()
|
||||
|
||||
|
||||
def process_year(MONTHS, monthly_events):
|
||||
"""process full year and return list of events"""
|
||||
|
||||
def process_month(MONTHS, monthly_events, week_of_month, week, events):
|
||||
"""process one MONTHS of events"""
|
||||
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
|
||||
|
||||
|
||||
def process_months(MONTHS, monthly_events):
|
||||
"""process full year of MONTHS 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()
|
||||
|
||||
events = process_month(MONTHS, monthly_events, week_of_month, week, events)
|
||||
return events
|
||||
|
||||
@click.command()
|
||||
def main():
|
||||
"""create csv file"""
|
||||
events = process_year(MONTHS, monthly_events)
|
||||
events = process_months(MONTHS, monthly_events)
|
||||
events = sort_events(events)
|
||||
write_calendar(events)
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in New Issue
Block a user