blob: 01922c969832d35c11f0f981ff84c97bed13d4f4 [file] [log] [blame]
Patrick Williamsa90b01e2016-10-09 16:19:52 -05001#!/bin/env python
2import sdbusplus
3import mako.lookup
4import argparse
Patrick Williamsaffeafa2016-10-17 11:40:13 -05005import sys
Patrick Williamsa90b01e2016-10-09 16:19:52 -05006
7def main():
8 valid_types = { 'interface': sdbusplus.Interface }
Patrick Williams04e007f2016-10-15 07:15:12 -05009 valid_processes = { 'markdown' : "markdown",
Patrick Williams831839a2016-10-16 18:09:00 -050010 'server-header' : "server_header",
11 'server-cpp' : "server_cpp" }
Patrick Williamsa90b01e2016-10-09 16:19:52 -050012
13 parser = argparse.ArgumentParser(description='Process sdbus++ YAML files.')
14
15 parser.add_argument('-r', '--rootdir', dest='rootdir', default='example',
16 type=str, help='Location of files to process.')
17 parser.add_argument('-t', '--templatedir', dest='templatedir',
18 default='templates', type=str,
19 help='Location of templates files.')
20 parser.add_argument('typeName', metavar='TYPE', type=str,
21 choices=valid_types.keys(), help='Type to operate on.')
22 parser.add_argument('process', metavar='PROCESS', type=str,
23 choices=valid_processes.keys(),
24 help='Process to apply.')
25 parser.add_argument('item', metavar='ITEM', type=str,
26 help='Item to process.')
27
28 args = parser.parse_args();
29
Patrick Williamsaffeafa2016-10-17 11:40:13 -050030 if sys.version_info < (3,0):
31 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir],
32 disable_unicode=True)
33 else:
34 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
Patrick Williamsa90b01e2016-10-09 16:19:52 -050035
36 instance = valid_types[args.typeName].load(args.item, args.rootdir)
Patrick Williams24e8ae62016-10-14 18:24:38 -050037 function = getattr(instance, valid_processes[args.process])
Patrick Williamsa90b01e2016-10-09 16:19:52 -050038 print(function(lookup))
39
40if __name__ == '__main__':
41 main()