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 "-e", 17 "--extra_props_yaml", 18 dest="extra_props_yaml", 19 default="extra-properties-example.yaml", 20 help="input extra properties yaml file to parse", 21 ) 22 args = parser.parse_args() 23 24 with open(os.path.join(script_dir, args.extra_props_yaml), "r") as fd: 25 yamlDict = yaml.safe_load(fd) 26 27 # Render the mako template 28 template = os.path.join(script_dir, "extra-properties.mako.hpp") 29 t = Template(filename=template) 30 with open("extra-properties-gen.hpp", "w") as fd: 31 fd.write(t.render(dict=yamlDict)) 32 33 34if __name__ == "__main__": 35 script_dir = os.path.dirname(os.path.realpath(__file__)) 36 main() 37