src/melody/inputs.py
def create_input(option, template_name, template_location="template"):

    '''create an input file using jinja2 by filling a template
    with the values from the option variable passed in.'''

    # restructure option list into jinja2 input format
    jinja2_input = {}
    for item in option:
        try:
            jinja2_input.update(item)
        except ValueError:
            raise RuntimeError(
                ("inputs.py, create_input : format of item '{0}' is not "
                 "supported. Expecting a dictionary.".format(str(item))))

    # load the template and fill it with the option variable contents
    import jinja2
    try:
        template_loader = jinja2.FileSystemLoader(searchpath=template_location)
        template_env = jinja2.Environment(loader=template_loader)
        template = template_env.get_template(template_name)
        output_text = template.render(jinja2_input)
    except jinja2.TemplateNotFound:
        raise RuntimeError("template '{0}' not found".format(template_name))
    # return the particular input file as a string
    return output_text
def create_input(option, template_name, template_location="template"):

    '''create an input file using jinja2 by filling a template
    with the values from the option variable passed in.'''

    # restructure option list into jinja2 input format
    jinja2_input = {}
    for item in option:
        try:
            jinja2_input.update(item)
        except ValueError:
            raise RuntimeError(
                ("inputs.py, create_input : format of item '{0}' is not "
                 "supported. Expecting a dictionary.".format(str(item))))

    # load the template and fill it with the option variable contents
    import jinja2
    try:
        template_loader = jinja2.FileSystemLoader(searchpath=template_location)
        template_env = jinja2.Environment(loader=template_loader)
        template = template_env.get_template(template_name)
        output_text = template.render(jinja2_input)
    except jinja2.TemplateNotFound:
        raise RuntimeError("template '{0}' not found".format(template_name))
    # return the particular input file as a string
    return output_text
def create_input ( option , template_name , template_location = "template" ) : # restructure option list into jinja2 input format jinja2_input = { } for item in option : try : jinja2_input . update ( item ) except ValueError : raise RuntimeError ( ( "inputs.py, create_input : format of item '{0}' is not " "supported. Expecting a dictionary." . format ( str ( item ) ) ) ) # load the template and fill it with the option variable contents import jinja2 try : template_loader = jinja2 . FileSystemLoader ( searchpath = template_location ) template_env = jinja2 . Environment ( loader = template_loader ) template = template_env . get_template ( template_name ) output_text = template . render ( jinja2_input ) except jinja2 . TemplateNotFound : raise RuntimeError ( "template '{0}' not found" . format ( template_name ) ) # return the particular input file as a string return output_text
create an input file using jinja2 by filling a template
    with the values from the option variable passed in.
create an input file using jinja2 by filling a template with the values from the option variable passed in .