xref: /openbmc/sdbusplus/tools/sdbus++ (revision a90b01e2)
1#!/bin/env python
2import sdbusplus
3import mako.lookup
4import argparse
5
6def main():
7    valid_types = { 'interface': sdbusplus.Interface }
8    valid_processes = { 'markdown' : "markdown" }
9
10    parser = argparse.ArgumentParser(description='Process sdbus++ YAML files.')
11
12    parser.add_argument('-r', '--rootdir', dest='rootdir', default='example',
13                        type=str, help='Location of files to process.')
14    parser.add_argument('-t', '--templatedir', dest='templatedir',
15                        default='templates', type=str,
16                        help='Location of templates files.')
17    parser.add_argument('typeName', metavar='TYPE', type=str,
18                        choices=valid_types.keys(), help='Type to operate on.')
19    parser.add_argument('process', metavar='PROCESS', type=str,
20                        choices=valid_processes.keys(),
21                        help='Process to apply.')
22    parser.add_argument('item', metavar='ITEM', type=str,
23                        help='Item to process.')
24
25    args = parser.parse_args();
26
27    lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
28
29    instance = valid_types[args.typeName].load(args.item, args.rootdir)
30    function = getattr(instance, args.process)
31    print(function(lookup))
32
33if __name__ == '__main__':
34    main()
35