Mercurial > hg > bzconsole
changeset 26:85357b075211
add ability to CC and use multiple whiteboard
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 14 Oct 2011 12:10:10 -0700 |
parents | b5cd8e22c868 |
children | d5e88dadde69 |
files | bzconsole/api.py setup.py |
diffstat | 2 files changed, 27 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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: