diff options
Diffstat (limited to 'settings_parser.py')
-rwxr-xr-x | settings_parser.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/settings_parser.py b/settings_parser.py new file mode 100755 index 0000000..46bb474 --- /dev/null +++ b/settings_parser.py @@ -0,0 +1,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)) |