changeset 9:b350ae6fe3c9

output dictionary return values as json
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 06 Nov 2010 14:57:43 -0700
parents f71a067fe81a
children 3cdbc94626b8
files bzconsole/command.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bzconsole/command.py	Thu Nov 04 16:23:35 2010 -0700
+++ b/bzconsole/command.py	Sat Nov 06 14:57:43 2010 -0700
@@ -3,6 +3,7 @@
 """
 
 import inspect
+import json
 import sys
 from optparse import OptionParser
 from pprint import pprint
@@ -100,6 +101,11 @@
         elif isinstance(retval, list):
             for i in retval:
                 print i
+        elif isinstance(retval, dict):
+            try:
+                print json.dumps(retval)
+            except:
+                pprint(retval)
         else:
             pprint(retval)
         return retval