summaryrefslogtreecommitdiff
path: root/cloudinit/simpletable.py
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2021-12-15 20:16:38 -0600
committerGitHub <noreply@github.com>2021-12-15 19:16:38 -0700
commitbae9b11da9ed7dd0b16fe5adeaf4774b7cc628cf (patch)
tree1fbb3269fc87e39832e3286ef42eefd2b23fcd44 /cloudinit/simpletable.py
parent2bcf4fa972fde686c2e3141c58e640640b44dd00 (diff)
downloadvyos-cloud-init-bae9b11da9ed7dd0b16fe5adeaf4774b7cc628cf.tar.gz
vyos-cloud-init-bae9b11da9ed7dd0b16fe5adeaf4774b7cc628cf.zip
Adopt Black and isort (SC-700) (#1157)
Applied Black and isort, fixed any linting issues, updated tox.ini and CI.
Diffstat (limited to 'cloudinit/simpletable.py')
-rw-r--r--cloudinit/simpletable.py26
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__()