blob: 605104672328b00580389969e202574eb63bf934 [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 }
Patrick Williams04e007f2016-10-15 07:15:12 -05008 valid_processes = { 'markdown' : "markdown",
Patrick Williams831839a2016-10-16 18:09:00 -05009 'server-header' : "server_header",
10 'server-cpp' : "server_cpp" }
Patrick Williamsa90b01e2016-10-09 16:19:52 -050011
12 parser = argparse.ArgumentParser(description='Process sdbus++ YAML files.')
13
14 parser.add_argument('-r', '--rootdir', dest='rootdir', default='example',
15 type=str, help='Location of files to process.')
16 parser.add_argument('-t', '--templatedir', dest='templatedir',
17 default='templates', type=str,
18 help='Location of templates files.')
19 parser.add_argument('typeName', metavar='TYPE', type=str,
20 choices=valid_types.keys(), help='Type to operate on.')
21 parser.add_argument('process', metavar='PROCESS', type=str,
22 choices=valid_processes.keys(),
23 help='Process to apply.')
24 parser.add_argument('item', metavar='ITEM', type=str,
25 help='Item to process.')
26
27 args = parser.parse_args();
28
29 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
30
31 instance = valid_types[args.typeName].load(args.item, args.rootdir)
Patrick Williams24e8ae62016-10-14 18:24:38 -050032 function = getattr(instance, valid_processes[args.process])
Patrick Williamsa90b01e2016-10-09 16:19:52 -050033 print(function(lookup))
34
35if __name__ == '__main__':
36 main()