| Jayanth Othayoth | 719c5f0 | 2020-03-09 03:54:13 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 | 
| Marri Devender Rao | 0deb287 | 2018-11-12 07:45:54 -0600 | [diff] [blame] | 2 |  | 
 | 3 | import os | 
 | 4 | import yaml | 
 | 5 | from mako.template import Template | 
 | 6 | import argparse | 
 | 7 |  | 
 | 8 | def main(): | 
 | 9 |     parser = argparse.ArgumentParser( | 
 | 10 |         description="OpenPOWER error map code generator") | 
 | 11 |  | 
 | 12 |     parser.add_argument( | 
 | 13 |         '-i', '--errors_map_yaml', dest='errors_map_yaml', | 
 | 14 |         default='errors_watch.yaml', help='input errors watch yaml file to parse') | 
 | 15 |     args = parser.parse_args() | 
 | 16 |  | 
 | 17 |     with open(os.path.join(script_dir, args.errors_map_yaml), 'r') as fd: | 
 | 18 |         yamlDict = yaml.safe_load(fd) | 
 | 19 |  | 
 | 20 |         # Render the mako template | 
 | 21 |         template = os.path.join(script_dir, 'errors_map.mako.hpp') | 
 | 22 |         t = Template(filename=template) | 
 | 23 |         with open('errors_map.hpp', 'w') as fd: | 
 | 24 |             fd.write( | 
 | 25 |                 t.render( | 
 | 26 |                     errDict=yamlDict)) | 
 | 27 |  | 
 | 28 |  | 
 | 29 | if __name__ == '__main__': | 
 | 30 |     script_dir = os.path.dirname(os.path.realpath(__file__)) | 
| Jayanth Othayoth | 719c5f0 | 2020-03-09 03:54:13 -0500 | [diff] [blame] | 31 |     main() |