blob: f0f195c23f8dba95b0d4f93013cd771416c74225 [file] [log] [blame]
Santosh Puranik3d7b4fe2020-04-02 23:27:22 +05301#!/usr/bin/env python3
Deepak Kodihallibdfd1232017-02-17 00:29:02 -06002
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()