summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Searles-Bryant <samuel.searles-bryant@unipart.io>2019-08-22 11:42:48 +0100
committerSamuel Searles-Bryant <samuel.searles-bryant@unipart.io>2019-08-22 14:25:15 +0100
commit672ced8742f517b7d7e17c50edd50f3748575a05 (patch)
treefc9829b9227db3423371a91b7b19dc18111106eb
parent525bc9ef7a43e4f8a6120386435c8d94fb074820 (diff)
Change Formatter.table method to staticmethod
Make this a staticmethod so it's easier to use without needing to init a Formatter object first. Signed-off-by: Samuel Searles-Bryant <samuel.searles-bryant@unipart.io>
-rw-r--r--compose/cli/formatter.py6
-rw-r--r--compose/cli/main.py6
2 files changed, 7 insertions, 5 deletions
diff --git a/compose/cli/formatter.py b/compose/cli/formatter.py
index 6c0a3695..13794b89 100644
--- a/compose/cli/formatter.py
+++ b/compose/cli/formatter.py
@@ -18,9 +18,11 @@ def get_tty_width():
return int(width)
-class Formatter(object):
+class Formatter:
"""Format tabular data for printing."""
- def table(self, headers, rows):
+
+ @staticmethod
+ def table(headers, rows):
table = texttable.Texttable(max_width=get_tty_width())
table.set_cols_dtype(['t' for h in headers])
table.add_rows([headers] + rows)
diff --git a/compose/cli/main.py b/compose/cli/main.py
index 477b57b5..86da056e 100644
--- a/compose/cli/main.py
+++ b/compose/cli/main.py
@@ -613,7 +613,7 @@ class TopLevelCommand(object):
image_id,
size
])
- print(Formatter().table(headers, rows))
+ print(Formatter.table(headers, rows))
def kill(self, options):
"""
@@ -747,7 +747,7 @@ class TopLevelCommand(object):
container.human_readable_state,
container.human_readable_ports,
])
- print(Formatter().table(headers, rows))
+ print(Formatter.table(headers, rows))
def pull(self, options):
"""
@@ -987,7 +987,7 @@ class TopLevelCommand(object):
rows.append(process)
print(container.name)
- print(Formatter().table(headers, rows))
+ print(Formatter.table(headers, rows))
def unpause(self, options):
"""