blob: 6e606100d695a04d0c0ef0e1b9732e96a8851f79 [file] [log] [blame]
Marri Devender Rao0deb2872018-11-12 07:45:54 -06001#!/usr/bin/env python
2
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__))
31 main()