def write_table_in_format(template_format, outfile, template_values, show_table):
    # read template
    Template = tempita.HTMLTemplate if template_format == 'html' else tempita.Template
    template_file = TEMPLATE_FILE_NAME.format(format=template_format)
    try:
        template_content = __loader__.get_data(template_file).decode(TEMPLATE_ENCODING)
    except __HOLE__:
        with open(template_file, mode='r') as f:
            template_content = f.read()
    template = Template(template_content, namespace=TEMPLATE_NAMESPACE)

    result = template.substitute(**template_values)

    # write file
    if not outfile:
        print(result, end='')
    else:
        with open(outfile, 'w') as file:
            file.write(result)

        if show_table:
            try:
                with open(os.devnull, 'w') as devnull:
                    subprocess.Popen(['xdg-open', outfile],
                                     stdout=devnull, stderr=devnull)
            except OSError:
                pass
dataset/ETHPy150Open sosy-lab/benchexec/benchexec/tablegenerator/__init__.py/write_table_in_format