Adriana Kobylak | 4c60e5e | 2016-01-10 15:22:45 -0600 | [diff] [blame] | 1 | #!/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 | |
| 7 | import yaml |
Patrick Williams | 7ce37e8 | 2016-04-01 16:47:33 -0500 | [diff] [blame] | 8 | import pprint |
Adriana Kobylak | 4c60e5e | 2016-01-10 15:22:45 -0600 | [diff] [blame] | 9 | |
| 10 | SETTINGS_FILE = 'settings.yaml' |
| 11 | OUTPUT_FILE = 'settings_file.py' |
| 12 | FILE_HEADER = '#!/usr/bin/python -u' |
| 13 | |
| 14 | with open(SETTINGS_FILE) as s: |
| 15 | data = yaml.safe_load(s) |
| 16 | |
| 17 | with open(OUTPUT_FILE, 'w') as f: |
| 18 | f.write(FILE_HEADER) |
| 19 | f.write('\n') |
Patrick Williams | 7ce37e8 | 2016-04-01 16:47:33 -0500 | [diff] [blame] | 20 | f.write('SETTINGS=\\\n') |
| 21 | pprint.pprint(data, stream=f) |