diff options
Diffstat (limited to 'cloudinit/simpletable.py')
-rw-r--r-- | cloudinit/simpletable.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/cloudinit/simpletable.py b/cloudinit/simpletable.py index ca663cce..90281e06 100644 --- a/cloudinit/simpletable.py +++ b/cloudinit/simpletable.py @@ -22,27 +22,33 @@ class SimpleTable(object): def update_column_widths(self, values): for i, value in enumerate(values): - self.column_widths[i] = max( - len(value), - self.column_widths[i]) + self.column_widths[i] = max(len(value), self.column_widths[i]) def add_row(self, values): if len(values) > len(self.fields): - raise TypeError('too many values') + raise TypeError("too many values") values = [str(value) for value in values] self.rows.append(values) self.update_column_widths(values) def _hdiv(self): """Returns a horizontal divider for the table.""" - return '+' + '+'.join( - ['-' * (w + 2) for w in self.column_widths]) + '+' + return ( + "+" + "+".join(["-" * (w + 2) for w in self.column_widths]) + "+" + ) def _row(self, row): """Returns a formatted row.""" - return '|' + '|'.join( - [col.center(self.column_widths[i] + 2) - for i, col in enumerate(row)]) + '|' + return ( + "|" + + "|".join( + [ + col.center(self.column_widths[i] + 2) + for i, col in enumerate(row) + ] + ) + + "|" + ) def __str__(self): """Returns a string representation of the table with lines around. @@ -56,7 +62,7 @@ class SimpleTable(object): """ lines = [self._hdiv(), self._row(self.fields), self._hdiv()] lines += [self._row(r) for r in self.rows] + [self._hdiv()] - return '\n'.join(lines) + return "\n".join(lines) def get_string(self): return self.__str__() |