forked from enlightenment/expedite
parent
ee723772fe
commit
251a120ed3
|
@ -6,6 +6,10 @@ import os.path
|
|||
import csv
|
||||
from optparse import OptionParser
|
||||
|
||||
fmttext = '%(value)7.2f (%(percentual)+6.1f%%)'
|
||||
fmthtml = '%(value)7.2f <span style="color: #666; width: 55pt; display: inline-block; text-align: right; text-shadow: #999 1px 1px 3px;">(%(percentual)+0.1f%%)</span>'
|
||||
|
||||
|
||||
parser = OptionParser(usage="%prog [options] <reference> <file2> .. <fileN>",
|
||||
description="""\
|
||||
Generate reports comparing two or more outputs of expedite.
|
||||
|
@ -23,10 +27,12 @@ parser.add_option("-r", "--report",
|
|||
"[default=%default]"),
|
||||
action="store", type="choice", default="text",
|
||||
choices=["text", "html"])
|
||||
parser.add_option("-p", "--percentual",
|
||||
help=("show percentual instead of raw numbers for "
|
||||
"non-reference values."),
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-F", "--format",
|
||||
help=("format to use as python format string, "
|
||||
"valid keys are: value and percentual. "
|
||||
"[defaults: html=\"%s\", text=\"%s\"]" %
|
||||
(fmthtml, fmttext)),
|
||||
action="store", type="str", default=None)
|
||||
parser.add_option("-C", "--no-color", dest="color",
|
||||
help="do not use color in reports.",
|
||||
action="store_false", default=True)
|
||||
|
@ -35,6 +41,11 @@ options, files = parser.parse_args()
|
|||
if len(files) < 2:
|
||||
raise SystemExit("need at least 2 files to compare")
|
||||
|
||||
if options.format is None:
|
||||
if options.report == "html":
|
||||
options.format = fmthtml
|
||||
else:
|
||||
options.format = fmttext
|
||||
|
||||
ref_f = files[0]
|
||||
others_f = files[1:]
|
||||
|
@ -54,10 +65,14 @@ for f in files:
|
|||
def report_text():
|
||||
test_name_fmt = "%%%ds:" % max_test_name
|
||||
|
||||
fmtsize = len(options.format % {"value": 12345.67, "percentual": 1234.56})
|
||||
hdrfmt = "%%%d.%ds" % (fmtsize, fmtsize)
|
||||
|
||||
print test_name_fmt % "\\",
|
||||
for f in files:
|
||||
print "%7.7s" % (files[0][-7:],),
|
||||
for f in files[1:]:
|
||||
n, e = os.path.splitext(f)
|
||||
print "%7.7s" % n[-7:],
|
||||
print hdrfmt % n[-fmtsize:],
|
||||
print
|
||||
|
||||
if options.color and os.environ.get("TERM", "") == "xterm":
|
||||
|
@ -91,10 +106,10 @@ def report_text():
|
|||
else:
|
||||
c = color_equal
|
||||
|
||||
if options.percentual:
|
||||
print "%s%+6.1f%%%s" % (c, (percent * 100), color_reset),
|
||||
else:
|
||||
print "%s%7.2f%s" % (c, val, color_reset),
|
||||
fmt = options.format % {"value": val, "percentual": percent * 100}
|
||||
if len(fmt) < fmtsize:
|
||||
fmt = hdrfmt % fmt
|
||||
print "%s%s%s" % (c, fmt, color_reset),
|
||||
|
||||
print
|
||||
|
||||
|
@ -116,11 +131,27 @@ def report_html():
|
|||
<title>expedite comparison sheet: %(files)s</title>
|
||||
</head>
|
||||
<style type="text/css">
|
||||
table
|
||||
{
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
thead
|
||||
{
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
tr.overall-results
|
||||
{
|
||||
border-top: 1px solid black;
|
||||
font-weight: bold;
|
||||
}
|
||||
td.value, td.value-reference, td.value-missing, td.value-good, td.value-bad, td.value-equal
|
||||
{
|
||||
font-family: courier, monospaced;
|
||||
font-size: 10pt;
|
||||
text-align: right;
|
||||
border-left: 1px solid black;
|
||||
border-bottom: 1px dashed #ccc;
|
||||
}
|
||||
td.test-name, thead tr td { text-align: right; }\
|
||||
"""
|
||||
|
@ -133,6 +164,7 @@ def report_html():
|
|||
{
|
||||
font-weight: bold;
|
||||
background-color: #d9d9d9;
|
||||
border-bottom: 1px dashed #ccc;
|
||||
}
|
||||
"""
|
||||
|
||||
|
@ -160,11 +192,16 @@ def report_html():
|
|||
|
||||
def print_row(test):
|
||||
ref_val = data[ref_f][test]
|
||||
if "EVAS SPEED" in test.upper():
|
||||
extra_cls = ' class="overall-results"'
|
||||
else:
|
||||
extra_cls = ""
|
||||
|
||||
print """\
|
||||
<tr>
|
||||
<tr%s>
|
||||
<td class="test-name">%s</td>
|
||||
<td class="value-reference">%7.2f</td>\
|
||||
""" % (test, ref_val)
|
||||
""" % (extra_cls, test, ref_val)
|
||||
|
||||
for f in others_f:
|
||||
try:
|
||||
|
@ -183,10 +220,7 @@ def report_html():
|
|||
else:
|
||||
c = 'equal'
|
||||
|
||||
if options.percentual:
|
||||
v = "%+6.1f%%" % (percent * 100)
|
||||
else:
|
||||
v = "%7.2f" % val
|
||||
v = options.format % {"value": val, "percentual": percent * 100}
|
||||
|
||||
print """\
|
||||
<td class="value-%s">%s</td>\
|
||||
|
|
Loading…
Reference in New Issue