-
Notifications
You must be signed in to change notification settings - Fork 0
/
htocal.py
executable file
·40 lines (27 loc) · 919 Bytes
/
htocal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import csv
from writeCalendar import writeToCalendar, save
from changeOption import changeOption
from os import path
import shutil
import argparse
parser = argparse.ArgumentParser()
#-f FILE -wl LOCATION
parser.add_argument("-f", "--file", dest="file", help="CSV file")
parser.add_argument("-wl", "--worklocation", dest="worklocation", help="Work location")
args = parser.parse_args()
def main():
if args.worklocation:
changeOption("worklocation", args.worklocation)
if args.file:
file_name = args.file
with open(file_name, mode = "r") as file:
csvFile = csv.DictReader(file)
if not path.exists("options.json"):
shutil.copy("defaultOptions.json", "options.json")
for row in csvFile:
writeToCalendar(row)
save()
return
if __name__ == "__main__":
main()