| 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 | 
|  | 8 |  | 
|  | 9 | SETTINGS_FILE = 'settings.yaml' | 
|  | 10 | OUTPUT_FILE = 'settings_file.py' | 
|  | 11 | FILE_HEADER = '#!/usr/bin/python -u' | 
|  | 12 |  | 
|  | 13 | with open(SETTINGS_FILE) as s: | 
|  | 14 | data = yaml.safe_load(s) | 
|  | 15 |  | 
|  | 16 | with open(OUTPUT_FILE, 'w') as f: | 
|  | 17 | f.write(FILE_HEADER) | 
|  | 18 | f.write('\n') | 
|  | 19 | f.write('SETTINGS=') | 
|  | 20 | f.write(str(data)) |