-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyamlio.py
More file actions
30 lines (25 loc) · 694 Bytes
/
yamlio.py
File metadata and controls
30 lines (25 loc) · 694 Bytes
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
'''
Created on Jan 2, 2016
@author: jglover,ddorroh
'''
import yaml
import substitute
def read_yaml(path):
'''
Read YAML file from file path.
:return:
dictionary of the yaml configuration
'''
with open(path,'r') as read_f:
return yaml.load(read_f)
def read_and_substitute_yaml(path):
'''
Read YAML file from file path and canonicalize variables by recursive substitution.
:return:
dictionary of the yaml configuration
'''
yaml_config = read_yaml(path)
for key,value in yaml_config.iteritems():
if isinstance(value, str):
yaml_config[key] = substitute(value,**yaml_config)
return yaml_config