blob: e68685ddfb09463af643b2a623ea4d346c0176e3 [file] [log] [blame]
Patrick Williamsa90b01e2016-10-09 16:19:52 -05001#!/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)
Patrick Williams24e8ae62016-10-14 18:24:38 -050030 function = getattr(instance, valid_processes[args.process])
Patrick Williamsa90b01e2016-10-09 16:19:52 -050031 print(function(lookup))
32
33if __name__ == '__main__':
34 main()