Commit 17baff68 authored by Tarik Graba's avatar Tarik Graba 😷
Browse files

Add command line arguments to specify in and out filenames

parent d2a62705
......@@ -4,16 +4,38 @@ from icalendar import Calendar, Event
from datetime import datetime
from pytz import timezone
# Parse arguments
import argparse
parser = argparse.ArgumentParser()
CSV_FNAME = 'PACT.csv'
ICS_FNAME = 'PACT.ics'
requiredArgs = parser.add_argument_group('required named arguments')
requiredArgs.add_argument("-i","--csv", help="input csv file", required=True)
requiredArgs.add_argument("-o","--ics", help="output ics file", required=True)
parser.add_argument("-c","--summary",
help="summary that will be added to the ics, otherwise, the input file name is usted",
required=False)
args = parser.parse_args()
CSV_FNAME = args.csv
ICS_FNAME = args.ics
if args.summary:
SUMMARY = args.summary
else:
# The name of the CSV files generated by Synapses are informative
import os
SUMMARY = os.path.splitext(os.path.basename(CSV_FNAME))[0]
# Conversion
date_fmt="%d/%m/%Y %H:%M"
date_locale = timezone('Europe/Paris')
cal = Calendar()
cal['summary'] = 'EDT PACT'
cal['summary'] = SUMMARY
with open(CSV_FNAME) as csvfile:
seances = csv.reader(csvfile, delimiter=';', quotechar='"')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment