diff options
author | Will Woods <wwoods@redhat.com> | 2008-06-10 14:54:15 -0400 |
---|---|---|
committer | Will Woods <wwoods@redhat.com> | 2008-06-10 14:54:15 -0400 |
commit | 68299ba63acc14fc38f2dc2c7fd1373c0aff1119 (patch) | |
tree | 60004e19b4962c128dfe001fb91371bded023f87 /bugzilla/base.py | |
parent | 4782cbf51cdf89faa977ccace668f75e97e21e6d (diff) | |
download | python-bugzilla-68299ba63acc14fc38f2dc2c7fd1373c0aff1119.tar.gz python-bugzilla-68299ba63acc14fc38f2dc2c7fd1373c0aff1119.tar.xz python-bugzilla-68299ba63acc14fc38f2dc2c7fd1373c0aff1119.zip |
Explicitly mark methods unsupported by bugzilla3.0. Change the format of the .product attribute to be more like Bugzilla 3.x.
Diffstat (limited to 'bugzilla/base.py')
-rw-r--r-- | bugzilla/base.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/bugzilla/base.py b/bugzilla/base.py index 1be4224..554d89f 100644 --- a/bugzilla/base.py +++ b/bugzilla/base.py @@ -273,7 +273,13 @@ class BugzillaBase(object): fdel=lambda self: setattr(self,"_querydefaults",None)) def getproducts(self,force_refresh=False): - '''Return a dict of product names and product descriptions.''' + '''Get product data: names, descriptions, etc. + The data varies between Bugzilla versions but the basic format is a + list of dicts, where the dicts will have at least the following keys: + {'id':1,'name':"Some Product",'description':"This is a product"} + + Any method that requires a 'product' can be given either the + id or the name.''' if force_refresh or not self._products: self._products = self._getproducts() return self._products @@ -281,6 +287,17 @@ class BugzillaBase(object): # call and return it for each subsequent call. products = property(fget=lambda self: self.getproducts(), fdel=lambda self: setattr(self,'_products',None)) + def _product_id_to_name(self,productid): + '''Convert a product ID (int) to a product name (str).''' + # This will auto-create the 'products' list + for p in self.products: + if p['id'] == productid: + return p['name'] + def _product_name_to_id(self,product): + '''Convert a product name (str) to a product ID (int).''' + for p in self.products: + if p['name'] == product: + return p['id'] def getcomponents(self,product,force_refresh=False): '''Return a dict of components:descriptions for the given product.''' |