Patrick Williams | a90b01e | 2016-10-09 16:19:52 -0500 | [diff] [blame] | 1 | #!/bin/env python |
| 2 | import sdbusplus |
| 3 | import mako.lookup |
| 4 | import argparse |
| 5 | |
| 6 | def main(): |
| 7 | valid_types = { 'interface': sdbusplus.Interface } |
Patrick Williams | 04e007f | 2016-10-15 07:15:12 -0500 | [diff] [blame^] | 8 | valid_processes = { 'markdown' : "markdown", |
| 9 | 'server-header' : "server_header" } |
Patrick Williams | a90b01e | 2016-10-09 16:19:52 -0500 | [diff] [blame] | 10 | |
| 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 Williams | 24e8ae6 | 2016-10-14 18:24:38 -0500 | [diff] [blame] | 31 | function = getattr(instance, valid_processes[args.process]) |
Patrick Williams | a90b01e | 2016-10-09 16:19:52 -0500 | [diff] [blame] | 32 | print(function(lookup)) |
| 33 | |
| 34 | if __name__ == '__main__': |
| 35 | main() |