blob: 465f95cd5c7399b25d8977c5a992c12b139b6075 [file] [log] [blame]
#!/usr/bin/env python3
import argparse
import os
import yaml
from mako.template import Template
def main():
parser = argparse.ArgumentParser(
description="IPMI FRU VPD parser and code generator"
)
parser.add_argument(
"-e",
"--extra_props_yaml",
dest="extra_props_yaml",
default="extra-properties-example.yaml",
help="input extra properties yaml file to parse",
)
args = parser.parse_args()
with open(args.extra_props_yaml, "r") as fd:
yamlDict = yaml.safe_load(fd)
# Render the mako template
template = os.path.join(script_dir, "extra-properties.mako.cpp")
t = Template(filename=template)
with open("extra-properties-gen.cpp", "w") as fd:
fd.write(t.render(dict=yamlDict))
if __name__ == "__main__":
script_dir = os.path.dirname(os.path.realpath(__file__))
main()