changeset 38:81500171fda8

change output format
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 06 May 2010 18:01:03 -0700
parents 76fc1a23182c
children 30fc269a15c8
files profilemanager/command.py profilemanager/manager.py
diffstat 2 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/profilemanager/command.py	Thu May 06 17:52:06 2010 -0700
+++ b/profilemanager/command.py	Thu May 06 18:01:03 2010 -0700
@@ -162,9 +162,19 @@
 
         # invoke the command
         retval = getattr(_object, name)(*command_args, **command_options.__dict__)
+
+        # print the output
         if isinstance(retval, basestring):
             print retval
+        elif isinstance(retval, dict):
+            for key in sorted(retval.keys()):
+                print '%s: %s' % (key, retval[key])
+        elif hasattr(retval, '__iter__'):
+            for val in retval:
+                print val
         else:
             pprint(retval)
+
+        # return the value
         return retval
 
--- a/profilemanager/manager.py	Thu May 06 17:52:06 2010 -0700
+++ b/profilemanager/manager.py	Thu May 06 18:01:03 2010 -0700
@@ -91,13 +91,9 @@
         - directories : display the directories
         """
         profiles = self.profiles_dict()
-        retval = []
-        for name in sorted(profiles.keys()):
-            values = [name]
-            if directories:
-                values.append(self.path(name))
-            retval.append(values)
-        return format_tabular(retval) # XXX: TBD upstream
+        if not directories:
+            return sorted(profiles.keys())
+        return dict([(name, self.path(name)) for name in profiles.keys()])
 
     def clone(self, source, dest, hash=True):
         """