blob: b77f8304e098de18e811b41c561e88d766970fab [file] [log] [blame]
Santosh Puranik3d7b4fe2020-04-02 23:27:22 +05301#!/usr/bin/env python3
Deepak Kodihalli8457f822016-11-29 06:05:39 -06002
3import os
4import yaml
5from mako.template import Template
Deepak Kodihallicd6d2412017-02-06 07:35:32 -06006import argparse
Deepak Kodihalli8457f822016-11-29 06:05:39 -06007
Deepak Kodihallicd6d2412017-02-06 07:35:32 -06008def main():
9 parser = argparse.ArgumentParser(
10 description="OpenPOWER FRU VPD parser and code generator")
11
12 parser.add_argument(
13 '-i', '--inventory_yaml', dest='inventory_yaml',
14 default='writefru.yaml', help='input inventory yaml file to parse')
15 args = parser.parse_args()
16
17 with open(os.path.join(script_dir, args.inventory_yaml), 'r') as fd:
Deepak Kodihalli8457f822016-11-29 06:05:39 -060018 yamlDict = yaml.safe_load(fd)
19
20 # Render the mako template
21 template = os.path.join(script_dir, 'writefru.mako.hpp')
22 t = Template(filename=template)
23 with open('writefru.hpp', 'w') as fd:
24 fd.write(
25 t.render(
26 fruDict=yamlDict))
Deepak Kodihallicd6d2412017-02-06 07:35:32 -060027
28
29if __name__ == '__main__':
30 script_dir = os.path.dirname(os.path.realpath(__file__))
31 main()