Mercurial > mozilla > hg > ProfileManager
comparison profilemanager/command.py @ 38:81500171fda8
change output format
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Thu, 06 May 2010 18:01:03 -0700 |
| parents | ca57920aa223 |
| children | 3b53d584195f |
comparison
equal
deleted
inserted
replaced
| 37:76fc1a23182c | 38:81500171fda8 |
|---|---|
| 160 if len(command_args) != len(command['args']) and not command['varargs']: | 160 if len(command_args) != len(command['args']) and not command['varargs']: |
| 161 commandparser.error("Too many arguments given") | 161 commandparser.error("Too many arguments given") |
| 162 | 162 |
| 163 # invoke the command | 163 # invoke the command |
| 164 retval = getattr(_object, name)(*command_args, **command_options.__dict__) | 164 retval = getattr(_object, name)(*command_args, **command_options.__dict__) |
| 165 | |
| 166 # print the output | |
| 165 if isinstance(retval, basestring): | 167 if isinstance(retval, basestring): |
| 166 print retval | 168 print retval |
| 169 elif isinstance(retval, dict): | |
| 170 for key in sorted(retval.keys()): | |
| 171 print '%s: %s' % (key, retval[key]) | |
| 172 elif hasattr(retval, '__iter__'): | |
| 173 for val in retval: | |
| 174 print val | |
| 167 else: | 175 else: |
| 168 pprint(retval) | 176 pprint(retval) |
| 177 | |
| 178 # return the value | |
| 169 return retval | 179 return retval |
| 170 | 180 |
