/
lib.py
24 lines (23 loc) · 1.03 KB
/
lib.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
def isint(string):
try:
int(string)
return True
except ValueError:
return False
def parse_sheet_configuration(configuration_list):
configuration = {}
for item in configuration_list:
parts = item.split()
if (len(parts) == 2 and parts[0].lower() == "skiprows" and isint(parts[1])):
configuration['skipRows'] = max(int(parts[1]), 0)
if (len(parts) == 2 and parts[0].lower() == "headerrows" and isint(parts[1])):
configuration['headerRows'] = max(int(parts[1]), 1)
if (len(parts) == 1 and parts[0].lower() == "ignore"):
configuration['ignore'] = True
if (len(parts) == 1 and parts[0].lower() in ("hashcomments", "hashcomment")):
configuration['hashcomments'] = True
if (len(parts) == 2 and parts[0].lower() == "xmlroottag"):
configuration['XMLRootTag'] = parts[1]
if (len(parts) == 2 and parts[0].lower() == "rootlistpath"):
configuration['RootListPath'] = parts[1]
return configuration