# HG changeset patch # User Jeff Hammel # Date 1318619410 25200 # Node ID 85357b0752112db4ffd34a2f7683300936b087a8 # Parent b5cd8e22c86831a016a98d05c5722dd3d7e7c0a8 add ability to CC and use multiple whiteboard diff -r b5cd8e22c868 -r 85357b075211 bzconsole/api.py --- a/bzconsole/api.py Mon May 09 08:41:13 2011 -0700 +++ b/bzconsole/api.py Fri Oct 14 12:10:10 2011 -0700 @@ -68,8 +68,13 @@ del retval[d] return retval, dupe + def users(self, match): + """returns users matching a search string""" + assert self.username and self.password, "Must be authenticated" + return self._request('/user?match=%s' % match) + def new(self, component, title, product=None, - version=None, description=None, whiteboard=None): + version=None, description=None, whiteboard=(), cc=()): """file a new bug. username and password must be set""" # sanity check @@ -92,17 +97,28 @@ break assert version in self._configuration['product'][product]['version'], 'Version not found' + # create the needed data structure + request = dict(product=product, component=component, + summary=title, version=version, + op_sys='All', platform='All',) + + # add CC, if given + if cc: + if isinstance(cc, basestring): + cc=[cc] + users = [] + for match in cc: + user = self.users(match)['users'] + assert len(user) == 1, 'Non-unique user: %s' % match + users.append(user[0]) + request['cc'] = users + # get the bug description if not description: description = tmpbuffer() assert description, "Must provide a non-empty description" - - # create the needed data structure - request = dict(product=product, component=component, - summary=title, version=version, - comments=[self._comment(description)], - op_sys='All', platform='All',) - + request['comments'] = [self._comment(description)] + # add whiteboard, if given if whiteboard: if isinstance(whiteboard, basestring): @@ -152,7 +168,8 @@ query['password'] = self.password if query: query = urllib.urlencode(query) - url += '?' + query + joiner = '?' in url and '&' or '?' + url += joiner + query headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} if data: diff -r b5cd8e22c868 -r 85357b075211 setup.py --- a/setup.py Mon May 09 08:41:13 2011 -0700 +++ b/setup.py Fri Oct 14 12:10:10 2011 -0700 @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = '0.1.1' +version = '0.2' readme = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.txt')