1#!/usr/bin/env python3
2
3import argparse
4import os
5
6import yaml
7from mako.template import Template
8
9
10def main():
11    parser = argparse.ArgumentParser(
12        description="OpenPOWER FRU VPD parser and code generator"
13    )
14
15    parser.add_argument(
16        "-i",
17        "--inventory_yaml",
18        dest="inventory_yaml",
19        default="writefru.yaml",
20        help="input inventory yaml file to parse",
21    )
22    args = parser.parse_args()
23
24    with open(os.path.join(script_dir, args.inventory_yaml), "r") as fd:
25        yamlDict = yaml.safe_load(fd)
26
27        # Render the mako template
28        template = os.path.join(script_dir, "writefru.mako.hpp")
29        t = Template(filename=template)
30        with open("writefru.hpp", "w") as fd:
31            fd.write(t.render(fruDict=yamlDict))
32
33
34if __name__ == "__main__":
35    script_dir = os.path.dirname(os.path.realpath(__file__))
36    main()
37