blob: 9e74f911fd7d1f3c3afad28c6f63cd94f8b50fe1 [file] [log] [blame]
Adriana Kobylak4c60e5e2016-01-10 15:22:45 -06001#!/usr/bin/python -u
2
3# Simple parser to create a python dictionary from a yaml file.
4# It saves the applications from doing the parsing and
5# adding dependencies to additional modules like yaml
6
7import yaml
Patrick Williams7ce37e82016-04-01 16:47:33 -05008import pprint
Adriana Kobylak4c60e5e2016-01-10 15:22:45 -06009
10SETTINGS_FILE = 'settings.yaml'
11OUTPUT_FILE = 'settings_file.py'
12FILE_HEADER = '#!/usr/bin/python -u'
13
14with open(SETTINGS_FILE) as s:
15 data = yaml.safe_load(s)
16
17with open(OUTPUT_FILE, 'w') as f:
18 f.write(FILE_HEADER)
19 f.write('\n')
Patrick Williams7ce37e82016-04-01 16:47:33 -050020 f.write('SETTINGS=\\\n')
21 pprint.pprint(data, stream=f)