Santosh Puranik | 3d7b4fe | 2020-04-02 23:27:22 +0530 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Deepak Kodihalli | bdfd123 | 2017-02-17 00:29:02 -0600 | [diff] [blame] | 2 | |
| 3 | import os |
| 4 | import yaml |
| 5 | from mako.template import Template |
| 6 | import argparse |
| 7 | |
| 8 | |
| 9 | def main(): |
| 10 | parser = argparse.ArgumentParser( |
| 11 | description="OpenPOWER FRU VPD parser and code generator") |
| 12 | |
| 13 | parser.add_argument( |
| 14 | '-e', '--extra_props_yaml', |
| 15 | dest='extra_props_yaml', |
| 16 | default='extra-properties-example.yaml', |
| 17 | help='input extra properties yaml file to parse') |
| 18 | args = parser.parse_args() |
| 19 | |
| 20 | with open(os.path.join(script_dir, args.extra_props_yaml), 'r') as fd: |
| 21 | yamlDict = yaml.safe_load(fd) |
| 22 | |
| 23 | # Render the mako template |
| 24 | template = os.path.join(script_dir, 'extra-properties.mako.hpp') |
| 25 | t = Template(filename=template) |
| 26 | with open('extra-properties-gen.hpp', 'w') as fd: |
| 27 | fd.write( |
| 28 | t.render( |
| 29 | dict=yamlDict)) |
| 30 | |
| 31 | |
| 32 | if __name__ == '__main__': |
| 33 | script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 34 | main() |