pass filename to writer, default calendar.csv
This commit is contained in:
parent
9707095cc1
commit
2ecb916a2f
10
main.py
10
main.py
@ -119,9 +119,9 @@ def create_event(name: str,
|
||||
# events.append(event)
|
||||
|
||||
|
||||
def write_calendar(events: list[Event]) -> None:
|
||||
def write_calendar(events: list[Event], filename) -> None:
|
||||
"""write calendar to csv file"""
|
||||
with open("calendar.csv", "w", encoding="utf-8") as handle:
|
||||
with open(filename, "w", encoding="utf-8") as handle:
|
||||
writer =DataclassWriter(handle, events, Event)
|
||||
writer.map("event_name").to("EVENT NAME")
|
||||
writer.map("venue_name").to("VENUE NAME")
|
||||
@ -176,10 +176,12 @@ def process_months(months, monthly_events, year):
|
||||
events = process_month(months, monthly_events, year, month, week_of_month, week, events)
|
||||
return events
|
||||
|
||||
# @click.argument('filename', type=click.File('w'), default="calendar.csv", required=False)
|
||||
@click.command()
|
||||
@click.option("--debug", "-d", is_flag=True, default=False, help="Print debug output")
|
||||
@click.option('--year', "-y", type=int, default=date.today().year, help='Specify the year.')
|
||||
def main(debug, year):
|
||||
@click.argument('filename', default="calendar.csv", required=False)
|
||||
def main(debug, year, filename):
|
||||
"""create csv file"""
|
||||
global DEBUG
|
||||
DEBUG = debug
|
||||
@ -187,7 +189,7 @@ def main(debug, year):
|
||||
monthly_events = initalize_events(EVENT_LIST)
|
||||
events = process_months(months, monthly_events, year)
|
||||
# events = sort_events(events)
|
||||
write_calendar(events)
|
||||
write_calendar(events, filename)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user