1#!/bin/env python 2import sdbusplus 3import mako.lookup 4import argparse 5import sys 6 7 8def main(): 9 valid_types = {'interface': sdbusplus.Interface} 10 valid_processes = {'markdown': "markdown", 11 'server-header': "server_header", 12 'server-cpp': "server_cpp"} 13 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 29 args = parser.parse_args() 30 31 if sys.version_info < (3, 0): 32 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir], 33 disable_unicode=True) 34 else: 35 lookup = mako.lookup.TemplateLookup(directories=[args.templatedir]) 36 37 instance = valid_types[args.typeName].load(args.item, args.rootdir) 38 function = getattr(instance, valid_processes[args.process]) 39 print(function(lookup)) 40 41if __name__ == '__main__': 42 main() 43