Method: pylint.reporters.ureports.text_writer.TextWriter.default_table
Calls: 10, Exceptions: 0, Paths: 1Back
Path 1: 10 calls (1.0)
Table (10)
list (10)
[8, 6, 10, 10, 11, 8] (2) [9, 6, 5, 8, 10] (2) [24, 5, 8, 10] (2) [10, 6, 8, 10] (2) [15, 11] (1) [24, 11] (1)
1def default_table(
2 self, layout: Table, table_content: list[list[str]], cols_width: list[int]
3 ) -> None:
4 """Format a table."""
5 cols_width = [size + 1 for size in cols_width]
6 format_strings = " ".join(["%%-%ss"] * len(cols_width))
7 format_strings %= tuple(cols_width)
8
9 table_linesep = "\n+" + "+".join("-" * w for w in cols_width) + "+\n"
10 headsep = "\n+" + "+".join("=" * w for w in cols_width) + "+\n"
11
12 self.write(table_linesep)
13 split_strings = format_strings.split(" ")
14 for index, line in enumerate(table_content):
15 self.write("|")
16 for line_index, at_index in enumerate(line):
17 self.write(split_strings[line_index] % at_index)
18 self.write("|")
19 if index == 0 and layout.rheaders:
20 self.write(headsep)
21 else:
22 self.write(table_linesep)