summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas De loof <nicolas.deloof@gmail.com>2019-10-08 16:24:40 +0200
committerGitHub <noreply@github.com>2019-10-08 16:24:40 +0200
commit1f16a7929d52283aea7e9c343810c2d0e00017bd (patch)
treefecf08460986c7f4b7a2d334d9f3595ecb091064
parentf9113202e83fcd7f5c91cd8878305357009e8c1e (diff)
parent672ced8742f517b7d7e17c50edd50f3748575a05 (diff)
Merge pull request #6864 from samueljsb/formatter_class
Change Formatter.table method to staticmethod
-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 b94f41ee..9e01b539 100644
--- a/compose/cli/main.py
+++ b/compose/cli/main.py
@@ -620,7 +620,7 @@ class TopLevelCommand(object):
image_id,
size
])
- print(Formatter().table(headers, rows))
+ print(Formatter.table(headers, rows))
def kill(self, options):
"""
@@ -754,7 +754,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):
"""
@@ -994,7 +994,7 @@ class TopLevelCommand(object):
rows.append(process)
print(container.name)
- print(Formatter().table(headers, rows))
+ print(Formatter.table(headers, rows))
def unpause(self, options):
"""