blob: 57053f7f45093a60780a723b4e48c3b34df79382 [file] [log] [blame]
Patrick Williams2b7152f2020-04-02 07:18:32 -05001#!/usr/bin/env python3
Deepak Kodihalli5de09572017-05-16 23:53:40 -05002
3import os
4import yaml
5from mako.template import Template
6import argparse
7
Gunnar Millsa16abc52018-01-27 10:02:34 -06008
Deepak Kodihalli5de09572017-05-16 23:53:40 -05009def main():
10 parser = argparse.ArgumentParser(
11 description="Settings YAML parser and code generator")
12
13 parser.add_argument(
14 '-i', '--settings_yaml', dest='settings_yaml',
15 default='settings_example.yaml', help='settings yaml file to parse')
16 args = parser.parse_args()
17
18 with open(os.path.join(script_dir, args.settings_yaml), 'r') as fd:
19 yamlDict = yaml.safe_load(fd)
20
21 # Render the mako template
22 template = os.path.join(script_dir, 'settings_manager.mako.hpp')
23 t = Template(filename=template)
24 with open('settings_manager.hpp', 'w') as fd:
25 fd.write(
26 t.render(
27 settingsDict=yamlDict))
28
29
30if __name__ == '__main__':
31 script_dir = os.path.dirname(os.path.realpath(__file__))
32 main()