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