diff options
author | George Burgess IV <gbiv@google.com> | 2020-05-02 17:48:41 -0700 |
---|---|---|
committer | George Burgess <gbiv@chromium.org> | 2020-05-04 21:11:34 +0000 |
commit | b7cc8cd6bc3b0c9652b817e976cc4f58c96bd34d (patch) | |
tree | 5a608f83a2cb9d52185c85f8927d8cf0cf6ccd5a /cros_utils | |
parent | 663dcce7c7b32946bc57e46bae1f1b7370e4fbb2 (diff) | |
download | toolchain-utils-b7cc8cd6bc3b0c9652b817e976cc4f58c96bd34d.tar.gz |
cros_utils: fix a bad format string
`'%s' + 'bar' % baz` == `'%s' + ('bar' % baz)`, which raises an
exception. OTOH, `'%s' 'bar' % baz` == `('%s' 'bar') % baz`, so do that
instead.
BUG=None
TEST=Unittests
Change-Id: I83313e8fcb34d4ca923f3730133eec528ea6f9eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2177144
Tested-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Tiancong Wang <tcwang@google.com>
Diffstat (limited to 'cros_utils')
-rw-r--r-- | cros_utils/tabulator.py | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/cros_utils/tabulator.py b/cros_utils/tabulator.py index 2cf4ffd7..b4092993 100644 --- a/cros_utils/tabulator.py +++ b/cros_utils/tabulator.py @@ -299,8 +299,8 @@ class SamplesTableGenerator(TableGenerator): all_runs_empty = all(not dict for label in bench_runs for dict in label) if all_runs_empty: cell = Cell() - cell.string_value = 'Benchmark %s contains no result.' + \ - ' Is the benchmark name valid?' % k + cell.string_value = ('Benchmark %s contains no result.' + ' Is the benchmark name valid?' % k) table.append([cell]) else: row = [k] @@ -1150,8 +1150,10 @@ class TableFormatter(object): result_name = column.result.__class__.__name__ format_name = column.fmt.__class__.__name__ - cell.string_value = '%s %s' % (result_name.replace('Result', ''), - format_name.replace('Format', '')) + cell.string_value = '%s %s' % ( + result_name.replace('Result', ''), + format_name.replace('Format', ''), + ) header.append(cell) @@ -1493,39 +1495,41 @@ def GetComplexTable(runs, labels, out_to=TablePrinter.CONSOLE): if __name__ == '__main__': # Run a few small tests here. - runs = [[{ - 'k1': '10', - 'k2': '12', - 'k5': '40', - 'k6': '40', - 'ms_1': '20', - 'k7': 'FAIL', - 'k8': 'PASS', - 'k9': 'PASS', - 'k10': '0' - }, - { - 'k1': '13', - 'k2': '14', - 'k3': '15', - 'ms_1': '10', - 'k8': 'PASS', - 'k9': 'FAIL', - 'k10': '0' - }], - [{ - 'k1': '50', - 'k2': '51', - 'k3': '52', - 'k4': '53', - 'k5': '35', - 'k6': '45', - 'ms_1': '200', - 'ms_2': '20', - 'k7': 'FAIL', - 'k8': 'PASS', - 'k9': 'PASS' - }]] + runs = [ + [{ + 'k1': '10', + 'k2': '12', + 'k5': '40', + 'k6': '40', + 'ms_1': '20', + 'k7': 'FAIL', + 'k8': 'PASS', + 'k9': 'PASS', + 'k10': '0' + }, + { + 'k1': '13', + 'k2': '14', + 'k3': '15', + 'ms_1': '10', + 'k8': 'PASS', + 'k9': 'FAIL', + 'k10': '0' + }], + [{ + 'k1': '50', + 'k2': '51', + 'k3': '52', + 'k4': '53', + 'k5': '35', + 'k6': '45', + 'ms_1': '200', + 'ms_2': '20', + 'k7': 'FAIL', + 'k8': 'PASS', + 'k9': 'PASS' + }], + ] labels = ['vanilla', 'modified'] t = GetComplexTable(runs, labels, TablePrinter.CONSOLE) print(t) |