#!/usr/bin/env python3
"""
Generate tests for softrvv
TODO(henryherman) Look into combining the different template workflows
"""
import os
import logging
import argparse
from collections import namedtuple
from pathlib import Path

from mako.lookup import TemplateLookup
import mako.exceptions

parser = argparse.ArgumentParser(
    description='Generate tests for vector instructions.')

parser.add_argument('--template-path', dest='template_path',
                    help='path to templates', required=True)
parser.add_argument('--template', dest='template_name',
                    help='template name', required=True)
parser.add_argument('-v', '--verbose', help='increase output verbosity',
                    action='store_true')
parser.add_argument('--out-path', dest='out_path',
                    help='Path to output files', default='.')
parser.add_argument('--op', dest='op',
                    help='op instruction', default='')

args = parser.parse_args()

if args.verbose:
    logging.basicConfig(level=logging.DEBUG)

def main():
    """ Main routine for generating softrvv tests from templates."""
    mylookup = TemplateLookup(directories=[args.template_path, "."])
    try:
        template = mylookup.get_template(args.template_name)
    except mako.exceptions.TopLevelLookupException:
        parser.error("Template does not exist %s" % args.template_name)
    logging.debug("Template %s found", args.template_name)
    Path(args.out_path).mkdir(parents=True, exist_ok=True)
    outfile_name = args.template_name.replace(".tpl", "")
    full_outfile_path = os.path.join(args.out_path, outfile_name)
    logging.debug("Generating file %s", full_outfile_path)
    with open(full_outfile_path, "w+") as outfile:
        outfile.write(template.render(op=args.op))

if __name__ == "__main__":
    main()


