summaryrefslogtreecommitdiffstats
path: root/settings_parser.py
blob: 46bb47446fe6fb136723968c2525aa4b5db0ba09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python -u

# Simple parser to create a python dictionary from a yaml file.
# It saves the applications from doing the parsing and
# adding dependencies to additional modules like yaml

import yaml

SETTINGS_FILE = 'settings.yaml'
OUTPUT_FILE = 'settings_file.py'
FILE_HEADER = '#!/usr/bin/python -u'

with open(SETTINGS_FILE) as s:
    data = yaml.safe_load(s)

with open(OUTPUT_FILE, 'w') as f:
    f.write(FILE_HEADER)
    f.write('\n')
    f.write('SETTINGS=')
    f.write(str(data))
OpenPOWER on IntegriCloud