-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
41 lines (34 loc) · 907 Bytes
/
utils.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
41
#Jack Dwyer 12-12-2012
import yaml
def parse_line(line):
try:
url, name = line.split(None, 1)
return (url, name.strip())
except ValueError:
return (line.strip(), )
def parse_settings(file):
details = []
for line in read_file(file):
details.append(parse_line(line))
return details
def read_file(file):
with open(file, 'r') as f:
line = f.readline()
while (line):
if not line:
continue
yield line
line = f.readline()
def read_yaml():
#Test function
supervisors = {}
with open("settings.yaml", 'r') as f:
config = yaml.load(f)
for k, vl in config.items():
if k == "DEFAULTS":
continue
supervisors[k] = vl
return supervisors
if __name__ == "__main__":
supervisors = read_yaml()
print supervisors