blob: 76998c9895a2f19bd9517b33ce78ea78d1a4ae6a [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
Patrick Williamsf5c3cde2016-10-21 11:49:01 -05007
Patrick Williamsa90b01e2016-10-09 16:19:52 -05008def main():
Patrick Williamsf5c3cde2016-10-21 11:49:01 -05009 valid_types = {'interface': sdbusplus.Interface}
10 valid_processes = {'markdown': "markdown",
11 'server-header': "server_header",
12 'server-cpp': "server_cpp"}
Patrick Williamsa90b01e2016-10-09 16:19:52 -050013
14 parser = argparse.ArgumentParser(description='Process sdbus++ YAML files.')
15
16 parser.add_argument('-r', '--rootdir', dest='rootdir', default='example',
17 type=str, help='Location of files to process.')
18 parser.add_argument('-t', '--templatedir', dest='templatedir',
19 default='templates', type=str,
20 help='Location of templates files.')
21 parser.add_argument('typeName', metavar='TYPE', type=str,
22 choices=valid_types.keys(), help='Type to operate on.')
23 parser.add_argument('process', metavar='PROCESS', type=str,
24 choices=valid_processes.keys(),
25 help='Process to apply.')
26 parser.add_argument('item', metavar='ITEM', type=str,
27 help='Item to process.')
28
Patrick Williamsf5c3cde2016-10-21 11:49:01 -050029 args = parser.parse_args()
Patrick Williamsa90b01e2016-10-09 16:19:52 -050030
Patrick Williamsf5c3cde2016-10-21 11:49:01 -050031 if sys.version_info < (3, 0):
Patrick Williamsaffeafa2016-10-17 11:40:13 -050032 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir],
33 disable_unicode=True)
34 else:
35 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])
Patrick Williamsa90b01e2016-10-09 16:19:52 -050036
37 instance = valid_types[args.typeName].load(args.item, args.rootdir)
Patrick Williams24e8ae62016-10-14 18:24:38 -050038 function = getattr(instance, valid_processes[args.process])
Patrick Williamsa90b01e2016-10-09 16:19:52 -050039 print(function(lookup))
40
41if __name__ == '__main__':
42 main()