blob: 47f05c6cf3f2e3c5ee5a824611e00281b7693864 [file] [log] [blame]
Jayanth Othayoth719c5f02020-03-09 03:54:13 -05001#!/usr/bin/env python3
Marri Devender Rao0deb2872018-11-12 07:45:54 -06002
3import os
4import yaml
5from mako.template import Template
6import argparse
7
8def 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
29if __name__ == '__main__':
30 script_dir = os.path.dirname(os.path.realpath(__file__))
Jayanth Othayoth719c5f02020-03-09 03:54:13 -050031 main()