Skip to content

Commit 235e648

Browse files
authored
Merge pull request opencv#19268 from fpetrogalli:tabs-summary-output
* [ts][summary.py] Extend `-o` to support tabs separated output. * [ts][summary.py] Improve TABS sepatated output. There is no need to print TAB at the beginning and at the end of each row in the table. Cosmetic change: using python list comprehension instead of for loop to process a single row.
1 parent fbcc532 commit 235e648

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

modules/ts/misc/summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def getSetName(tset, idx, columns, short = True):
3030
exit(0)
3131

3232
parser = OptionParser()
33-
parser.add_option("-o", "--output", dest="format", help="output results in text format (can be 'txt', 'html', 'markdown' or 'auto' - default)", metavar="FMT", default="auto")
33+
parser.add_option("-o", "--output", dest="format", help="output results in text format (can be 'txt', 'html', 'markdown', 'tabs' or 'auto' - default)", metavar="FMT", default="auto")
3434
parser.add_option("-m", "--metric", dest="metric", help="output metric", metavar="NAME", default="gmean")
3535
parser.add_option("-u", "--units", dest="units", help="units for output values (s, ms (default), us, ns or ticks)", metavar="UNITS", default="ms")
3636
parser.add_option("-f", "--filter", dest="filter", help="regex to filter tests", metavar="REGEX", default=None)

modules/ts/misc/table_formatter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class table(object):
3838
def __init__(self, caption = None, format=None):
3939
self.format = format
4040
self.is_markdown = self.format == 'markdown'
41+
self.is_tabs = self.format == 'tabs'
4142
self.columns = {}
4243
self.rows = []
4344
self.ridx = -1;
@@ -253,7 +254,7 @@ def getValue(self, name, *elements):
253254

254255
def consolePrintTable(self, out):
255256
columns = self.layoutTable()
256-
colrizer = getColorizer(out) if not self.is_markdown else dummyColorizer(out)
257+
colrizer = getColorizer(out) if not (self.is_markdown or self.is_tabs) else dummyColorizer(out)
257258

258259
if self.caption:
259260
out.write("%s%s%s" % ( os.linesep, os.linesep.join(self.reformatTextValue(self.caption)), os.linesep * 2))
@@ -299,6 +300,10 @@ def consolePrintRow2(self, out, r, columns):
299300
text = ' '.join(self.getValue('text', c) or [])
300301
out.write(text + "|")
301302
out.write(os.linesep)
303+
elif self.is_tabs:
304+
cols_to_join=[' '.join(self.getValue('text', c) or []) for c in row.cells]
305+
out.write('\t'.join(cols_to_join))
306+
out.write(os.linesep)
302307
else:
303308
for ln in range(row.minheight):
304309
i = 0

0 commit comments

Comments
 (0)