Пример #1
0
def write_html_table(out, options, title, run_sets, rows, stats,
                     relevant_id_columns, output_path, common_prefix,
                     **kwargs):
    app_css = [util.read_bundled_file(path + "css") for path in _REACT_FILES]
    app_js = [util.read_bundled_file(path + "js") for path in _REACT_FILES]
    benchmark_setup = _prepare_benchmark_setup_data(run_sets, common_prefix,
                                                    relevant_id_columns)
    columns = [run_set.columns for run_set in run_sets]
    stats = _prepare_stats(stats, rows, columns)
    tools = _prepare_run_sets_for_js(run_sets)
    href_base = os.path.dirname(
        options.xmltablefile) if options.xmltablefile else None
    rows_js = _prepare_rows_for_js(rows, output_path, href_base,
                                   relevant_id_columns)

    def write_tags(tag_name, contents):
        for content in contents:
            out.write("<")
            out.write(tag_name)
            out.write(">\n")
            out.write(content)
            out.write("\n</")
            out.write(tag_name)
            out.write(">\n")

    def write_json_part(name, value=None, last=False):
        out.write('  "')
        out.write(name)
        out.write('": ')
        out.write(json.dumps(value, sort_keys=True))
        if not last:
            out.write(",")
        out.write("\n")

    out.write("""<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="BenchExec table-generator {version}">
<title>{title} &ndash; BenchExec results</title>

""".format(title=title, version=__version__))
    write_tags("style", app_css)
    out.write("""<style>
    #msg-container {
        text-align: center;
        margin-top: 2rem;
        font-size: 1.2rem;
    }
</style>
</head>

<body>

<div id="msg-container">
    Please wait while the page is being loaded.
</div>
<div id="root">
</div>
<noscript>
  This is an interactive table for viewing results produced by
  <a href="https://github.com/sosy-lab/benchexec" target="_blank" rel="noopener noreferrer">BenchExec</a>.
  Please enable JavaScript to use it.
</noscript>
<script>
    try {
        [0].flat();
    } catch (err) {
        var msgContainer = document.getElementById("msg-container");
        msgContainer.innerHTML = "Your browser is not supported. Please consider using another browser such as Firefox or Google Chrome."
    }
</script>
<script>
const data = {
""")
    write_json_part("version", __version__)
    write_json_part("head", benchmark_setup)
    write_json_part("tools", tools)
    write_json_part("rows", rows_js)
    write_json_part("stats", stats, last=True)
    out.write("""};
window.data = data;
</script>

""")
    write_tags("script", app_js)
    out.write("</body>\n</html>\n")
Пример #2
0
def write_html_table(out, options, title, run_sets, rows, stats,
                     relevant_id_columns, output_path, common_prefix,
                     **kwargs):
    app_css = [util.read_bundled_file(path + "css") for path in _REACT_FILES]
    app_js = [util.read_bundled_file(path + "js") for path in _REACT_FILES]
    benchmark_setup = _prepare_benchmark_setup_data(run_sets, common_prefix,
                                                    relevant_id_columns)
    columns = [run_set.columns for run_set in run_sets]
    stats = _prepare_stats(stats, rows, columns)
    tools = _prepare_run_sets_for_js(run_sets)
    href_base = os.path.dirname(
        options.xmltablefile) if options.xmltablefile else None
    rows_js = _prepare_rows_for_js(rows, output_path, href_base,
                                   relevant_id_columns)

    def write_tags(tag_name, contents):
        for content in contents:
            out.write("<")
            out.write(tag_name)
            out.write(">\n")
            out.write(content)
            out.write("\n</")
            out.write(tag_name)
            out.write(">\n")

    def write_json_part(name, value=None, last=False):
        out.write('  "')
        out.write(name)
        out.write('": ')
        out.write(json.dumps(value, sort_keys=True))
        if not last:
            out.write(",")
        out.write("\n")

    out.write("""<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="BenchExec table-generator {version}">
<title>{title} &ndash; BenchExec results</title>

""".format(title=title, version=__version__))
    write_tags("style", app_css)
    out.write("""</head>
<body>

<div id="root"></div>
<noscript>
  This is an interactive table for viewing results produced by
  <a href="https://github.com/sosy-lab/benchexec" target="_blank" rel="noopener noreferrer">BenchExec</a>.
  Please enable JavaScript to use it.
</noscript>

<script>
const data = {
""")
    write_json_part("version", __version__)
    write_json_part("head", benchmark_setup)
    write_json_part("tools", tools)
    write_json_part("rows", rows_js)
    write_json_part("stats", stats, last=True)
    out.write("""};
window.data = data;
</script>

""")
    write_tags("script", app_js)
    out.write("</body>\n</html>\n")