1 # Copyright (C) 2005-2010 Aaron Bentley and Panometrics, Inc.
2 # Gianluca Montecchi <gian@grys.it>
3 # Marien Zwart <marienz@gentoo.org>
4 # Thomas Gerigk <tgerigk@gmx.de>
5 # W. Trevor King <wking@drexel.edu>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 import libbe.command.util
26 class Assign (libbe.command.Command):
27 """Assign an individual or group to fix a bug
30 >>> import libbe.bugdir
31 >>> bd = libbe.bugdir.SimpleBugDir(memory=False)
32 >>> io = libbe.command.StringInputOutput()
33 >>> io.stdout = sys.stdout
34 >>> ui = libbe.command.UserInterface(io=io)
35 >>> ui.storage_callbacks.set_storage(bd.storage)
36 >>> cmd = Assign(ui=ui)
38 >>> bd.bug_from_uuid('a').assigned is None
40 >>> ui._user_id = u'Fran\xe7ois'
41 >>> ret = ui.run(cmd, args=['-', '/a'])
43 >>> bd.bug_from_uuid('a').assigned
46 >>> ret = ui.run(cmd, args=['someone', '/a', '/b'])
48 >>> bd.bug_from_uuid('a').assigned
50 >>> bd.bug_from_uuid('b').assigned
53 >>> ret = ui.run(cmd, args=['none', '/a'])
55 >>> bd.bug_from_uuid('a').assigned is None
62 def __init__(self, *args, **kwargs):
63 libbe.command.Command.__init__(self, *args, **kwargs)
65 libbe.command.Argument(
66 name='assigned', metavar='ASSIGNED', default=None,
67 completion_callback=libbe.command.util.complete_assigned),
68 libbe.command.Argument(
69 name='bug-id', metavar='BUG-ID', default=None,
71 completion_callback=libbe.command.util.complete_bug_id),
74 def _run(self, **params):
75 assigned = params['assigned']
76 if assigned == 'none':
79 assigned = self._get_user_id()
80 bugdir = self._get_bugdir()
81 for bug_id in params['bug-id']:
83 libbe.command.util.bug_comment_from_user_id(bugdir, bug_id)
84 if bug.assigned != assigned:
85 bug.assigned = assigned
90 Assign a person to fix a bug.
92 Assigneds should be the person's Bugs Everywhere identity, the same
93 string that appears in Creator fields.
95 Special assigned strings:
96 "-" assign the bug to yourself
97 "none" un-assigns the bug