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