1#!/usr/bin/env python3
2
3import os
4import yaml
5from mako.template import Template
6import argparse
7
8
9def main():
10    parser = argparse.ArgumentParser(
11        description="IPMI 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.cpp')
25        t = Template(filename=template)
26        with open('extra-properties-gen.cpp', '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()
35