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