Always display the details if an ACL is specified.

Signed-off-by: Jean-Marc Eurin <jmeurin@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3131 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/acl.py b/cli/acl.py
index a6a01df..d6f5baa 100755
--- a/cli/acl.py
+++ b/cli/acl.py
@@ -123,9 +123,15 @@
 
 
     def output(self, results):
+        # If an ACL was specified, always print its details
+        if self.acls or self.verbose:
+            sublist_keys=('hosts', 'users')
+        else:
+            sublist_keys=()
+
         super(acl_list, self).output(results,
-                                     keys=['name', 'description'],
-                                     sublist_keys=['hosts', 'users'])
+                                     keys=('name', 'description'),
+                                     sublist_keys=sublist_keys)
 
 
 class acl_create(action_common.atest_create, acl):
diff --git a/cli/topic_common.py b/cli/topic_common.py
index 6d2129a..ce4de41 100755
--- a/cli/topic_common.py
+++ b/cli/topic_common.py
@@ -525,7 +525,7 @@
         return '  '.join(["%%-%ds" % lens[key] for key in keys])
 
 
-    def print_table_std(self, items, keys_header, sublist_keys={}):
+    def print_table_std(self, items, keys_header, sublist_keys=()):
         """Print a mix of header and lists in a user readable
         format
         The headers are justified, the sublist_keys are wrapped."""
@@ -538,14 +538,14 @@
             values = tuple(self.__conv_value(key, item[key])
                            for key in keys_header)
             print fmt % values
-            if self.verbose and sublist_keys:
+            if sublist_keys:
                 for key in sublist_keys:
                     self.print_wrapped(KEYS_TO_NAMES_EN[key],
                                        item[key])
                 print '\n'
 
 
-    def print_table_parse(self, items, keys_header, sublist_keys=[]):
+    def print_table_parse(self, items, keys_header, sublist_keys=()):
         """Print a mix of header and lists in a user readable
         format"""
         for item in items:
@@ -555,7 +555,7 @@
                       if self.__conv_value(key,
                                            item[key]) != '']
 
-            if self.verbose:
+            if sublist_keys:
                 [values.append('%s=%s'% (KEYS_TO_NAMES_EN[key],
                                          ','.join(item[key])))
                  for key in sublist_keys
diff --git a/cli/topic_common_unittest.py b/cli/topic_common_unittest.py
index 972f22d..75075db 100755
--- a/cli/topic_common_unittest.py
+++ b/cli/topic_common_unittest.py
@@ -842,14 +842,21 @@
 
 
     def test_print_mix_table(self):
-        self.__test_print_mix_table_std(['name', 'hostname'],
-                                        ['hosts', 'users'],
+        self.__test_print_mix_table_std(['name', 'hostname'], [],
                                         'Name   Host\n'
                                         'name0  h0\n'
                                         'name1  h1\n')
 
-    # TODO(jmeurin) Add actual test with sublist_keys.
 
+    def test_print_mix_table_sublist(self):
+        self.__test_print_mix_table_std(['name', 'hostname'], ['labels'],
+                                        'Name   Host\n'
+                                        'name0  h0\n'
+                                        'Labels: \n'
+                                        '\tl0, l1\n\n\n'
+                                        'name1  h1\n'
+                                        'Labels: \n'
+                                        '\tl2, l3\n\n\n')
 
 
     #