changeset 27:d5e88dadde69

add a bug command thingy
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 27 Jan 2012 14:10:03 -0800
parents 85357b075211
children a46a76a7990d
files bzconsole/api.py bzconsole/command.py setup.py
diffstat 3 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/bzconsole/api.py	Fri Oct 14 12:10:10 2011 -0700
+++ b/bzconsole/api.py	Fri Jan 27 14:10:03 2012 -0800
@@ -73,6 +73,11 @@
         assert self.username and self.password, "Must be authenticated"
         return self._request('/user?match=%s' % match)
 
+    def bug(self, number):
+        """display a bug"""
+        number = int(number)
+        return self._request('/bug/%d' % number)
+
     def new(self, component, title, product=None,
             version=None, description=None, whiteboard=(), cc=()):
         """file a new bug. username and password must be set"""
@@ -118,7 +123,7 @@
             description = tmpbuffer()
         assert description, "Must provide a non-empty description"
         request['comments'] = [self._comment(description)]
-        
+
         # add whiteboard, if given
         if whiteboard:
             if isinstance(whiteboard, basestring):
@@ -137,7 +142,7 @@
 
     def configuration(self):
         """bugzilla configuration"""
-        
+
         if not hasattr(self, '_configuration'):
             config_cache = os.path.join(os.environ['HOME'], self.config_cache)
             if not self.refresh:
--- a/bzconsole/command.py	Fri Oct 14 12:10:10 2011 -0700
+++ b/bzconsole/command.py	Fri Jan 27 14:10:03 2012 -0800
@@ -12,7 +12,7 @@
 class Undefined(object):
   def __init__(self, default):
     self.default=default
-    
+
 class CommandParser(OptionParser):
     # TODO: add `help` command
 
@@ -33,7 +33,7 @@
         # get class options
         init = self.command(_class.__init__)
         self.command2parser(init, self)
-            
+
         self.disable_interspersed_args()
 
     def add_option(self, *args, **kwargs):
@@ -136,7 +136,7 @@
                 print i
         elif isinstance(retval, dict):
             try:
-                print json.dumps(retval)
+                print json.dumps(retval, indent=2, sort_keys=True)
             except:
                 pprint(retval)
         else:
@@ -159,7 +159,7 @@
             optional = None
         command = { 'doc': doc,
                      'name': name,
-                     'args': args, 
+                     'args': args,
                      'optional': optional,
                      'varargs': argspec.varargs
                      }
--- a/setup.py	Fri Oct 14 12:10:10 2011 -0700
+++ b/setup.py	Fri Jan 27 14:10:03 2012 -0800
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.2'
+version = '0.2.1'
 
 readme = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.txt')