From 235e648bf5aa613b36f98bd84b7ee10a52aab40b Mon Sep 17 00:00:00 2001 From: Francesco Petrogalli <25690309+fpetrogalli@users.noreply.github.com> Date: Thu, 14 Jan 2021 12:01:36 +0000 Subject: [PATCH] Merge pull request #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. --- modules/ts/misc/summary.py | 2 +- modules/ts/misc/table_formatter.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/ts/misc/summary.py b/modules/ts/misc/summary.py index 5549b6c6dc..9da1fb60c6 100755 --- a/modules/ts/misc/summary.py +++ b/modules/ts/misc/summary.py @@ -30,7 +30,7 @@ if __name__ == "__main__": exit(0) parser = OptionParser() - 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") + 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") parser.add_option("-m", "--metric", dest="metric", help="output metric", metavar="NAME", default="gmean") parser.add_option("-u", "--units", dest="units", help="units for output values (s, ms (default), us, ns or ticks)", metavar="UNITS", default="ms") parser.add_option("-f", "--filter", dest="filter", help="regex to filter tests", metavar="REGEX", default=None) diff --git a/modules/ts/misc/table_formatter.py b/modules/ts/misc/table_formatter.py index d683394364..412936950f 100755 --- a/modules/ts/misc/table_formatter.py +++ b/modules/ts/misc/table_formatter.py @@ -38,6 +38,7 @@ class table(object): def __init__(self, caption = None, format=None): self.format = format self.is_markdown = self.format == 'markdown' + self.is_tabs = self.format == 'tabs' self.columns = {} self.rows = [] self.ridx = -1; @@ -253,7 +254,7 @@ class table(object): def consolePrintTable(self, out): columns = self.layoutTable() - colrizer = getColorizer(out) if not self.is_markdown else dummyColorizer(out) + colrizer = getColorizer(out) if not (self.is_markdown or self.is_tabs) else dummyColorizer(out) if self.caption: out.write("%s%s%s" % ( os.linesep, os.linesep.join(self.reformatTextValue(self.caption)), os.linesep * 2)) @@ -299,6 +300,10 @@ class table(object): text = ' '.join(self.getValue('text', c) or []) out.write(text + "|") out.write(os.linesep) + elif self.is_tabs: + cols_to_join=[' '.join(self.getValue('text', c) or []) for c in row.cells] + out.write('\t'.join(cols_to_join)) + out.write(os.linesep) else: for ln in range(row.minheight): i = 0