#!/bin/env python
import sdbusplus
import mako.lookup
import argparse
import sys
import os


def main():
    valid_types = {'interface': sdbusplus.Interface}
    valid_processes = {'markdown': "markdown",
                       'server-header': "server_header",
                       'server-cpp': "server_cpp"}

    parser = argparse.ArgumentParser(description='Process sdbus++ YAML files.')

    parser.add_argument('-r', '--rootdir', dest='rootdir', default='example',
                        type=str, help='Location of files to process.')
    parser.add_argument('-t', '--templatedir', dest='templatedir',
                        default=os.path.join('sdbusplus', 'templates'),
                        type=str, help='Location of templates files.')
    parser.add_argument('typeName', metavar='TYPE', type=str,
                        choices=valid_types.keys(), help='Type to operate on.')
    parser.add_argument('process', metavar='PROCESS', type=str,
                        choices=valid_processes.keys(),
                        help='Process to apply.')
    parser.add_argument('item', metavar='ITEM', type=str,
                        help='Item to process.')

    args = parser.parse_args()

    if sys.version_info < (3, 0):
        lookup = mako.lookup.TemplateLookup(directories=[args.templatedir],
                                            disable_unicode=True)
    else:
        lookup = mako.lookup.TemplateLookup(directories=[args.templatedir])

    instance = valid_types[args.typeName].load(args.item, args.rootdir)
    function = getattr(instance, valid_processes[args.process])
    print(function(lookup))

if __name__ == '__main__':
    main()
