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