Explorar o código

Merge pull request #6864 from samueljsb/formatter_class

Change Formatter.table method to staticmethod
Nicolas De loof %!s(int64=6) %!d(string=hai) anos
pai
achega
1f16a7929d
Modificáronse 2 ficheiros con 7 adicións e 5 borrados
  1. 4 2
      compose/cli/formatter.py
  2. 3 3
      compose/cli/main.py

+ 4 - 2
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)

+ 3 - 3
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):
         """