Merge pull request #6864 from samueljsb/formatter_class

Change Formatter.table method to staticmethod
This commit is contained in:
Nicolas De loof 2019-10-08 16:24:40 +02:00 committed by GitHub
commit 1f16a7929d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -18,9 +18,11 @@ def get_tty_width():
return int(width) return int(width)
class Formatter(object): class Formatter:
"""Format tabular data for printing.""" """Format tabular data for printing."""
def table(self, headers, rows):
@staticmethod
def table(headers, rows):
table = texttable.Texttable(max_width=get_tty_width()) table = texttable.Texttable(max_width=get_tty_width())
table.set_cols_dtype(['t' for h in headers]) table.set_cols_dtype(['t' for h in headers])
table.add_rows([headers] + rows) table.add_rows([headers] + rows)

View File

@ -620,7 +620,7 @@ class TopLevelCommand(object):
image_id, image_id,
size size
]) ])
print(Formatter().table(headers, rows)) print(Formatter.table(headers, rows))
def kill(self, options): def kill(self, options):
""" """
@ -754,7 +754,7 @@ class TopLevelCommand(object):
container.human_readable_state, container.human_readable_state,
container.human_readable_ports, container.human_readable_ports,
]) ])
print(Formatter().table(headers, rows)) print(Formatter.table(headers, rows))
def pull(self, options): def pull(self, options):
""" """
@ -994,7 +994,7 @@ class TopLevelCommand(object):
rows.append(process) rows.append(process)
print(container.name) print(container.name)
print(Formatter().table(headers, rows)) print(Formatter.table(headers, rows))
def unpause(self, options): def unpause(self, options):
""" """