blob: 728fc142315f3c5ace35aae1071b0bbe5cda495e [file] [log] [blame]
Deepak Kodihallibdfd1232017-02-17 00:29:02 -06001#!/usr/bin/env python
2
3import os
4import yaml
5from mako.template import Template
6import argparse
7
8
9def main():
10 parser = argparse.ArgumentParser(
11 description="OpenPOWER FRU VPD parser and code generator")
12
13 parser.add_argument(
14 '-e', '--extra_props_yaml',
15 dest='extra_props_yaml',
16 default='extra-properties-example.yaml',
17 help='input extra properties yaml file to parse')
18 args = parser.parse_args()
19
20 with open(os.path.join(script_dir, args.extra_props_yaml), 'r') as fd:
21 yamlDict = yaml.safe_load(fd)
22
23 # Render the mako template
24 template = os.path.join(script_dir, 'extra-properties.mako.hpp')
25 t = Template(filename=template)
26 with open('extra-properties-gen.hpp', 'w') as fd:
27 fd.write(
28 t.render(
29 dict=yamlDict))
30
31
32if __name__ == '__main__':
33 script_dir = os.path.dirname(os.path.realpath(__file__))
34 main()