1#!/usr/bin/env python3
2
3import os
4import yaml
5from mako.template import Template
6import argparse
7
8
9def main():
10    parser = argparse.ArgumentParser(
11        description="Callout code generator")
12
13    parser.add_argument(
14        '-i', '--callouts_yaml', dest='callouts_yaml',
15        default=os.path.join(script_dir, 'callouts-example.yaml'),
16        help='input callouts yaml')
17    args = parser.parse_args()
18
19    with open(args.callouts_yaml, 'r') as fd:
20        calloutsMap = yaml.safe_load(fd)
21
22        # Render the mako template
23        template = os.path.join(script_dir, 'callouts-gen.mako.hpp')
24        t = Template(filename=template)
25        with open('callouts-gen.hpp', 'w') as fd:
26            fd.write(
27                t.render(
28                    calloutsMap=calloutsMap))
29
30
31if __name__ == '__main__':
32    script_dir = os.path.dirname(os.path.realpath(__file__))
33    main()
34