1 # Copyright (C) 2005-2010 Aaron Bentley <abentley@panoramicfeedback.com>
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 file is part of Bugs Everywhere.
9 # Bugs Everywhere is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the
11 # Free Software Foundation, either version 2 of the License, or (at your
12 # option) any later version.
14 # Bugs Everywhere is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Bugs Everywhere. If not, see <http://www.gnu.org/licenses/>.
24 import libbe.command.util
27 class Assign (libbe.command.Command):
28 u"""Assign an individual or group to fix a bug
31 >>> import libbe.bugdir
32 >>> bd = libbe.bugdir.SimpleBugDir(memory=False)
33 >>> io = libbe.command.StringInputOutput()
34 >>> io.stdout = sys.stdout
35 >>> ui = libbe.command.UserInterface(io=io)
36 >>> ui.storage_callbacks.set_storage(bd.storage)
37 >>> cmd = Assign(ui=ui)
39 >>> bd.bug_from_uuid('a').assigned is None
41 >>> ui._user_id = u'Fran\xe7ois'
42 >>> ret = ui.run(cmd, args=['-', '/a'])
44 >>> bd.bug_from_uuid('a').assigned
47 >>> ret = ui.run(cmd, args=['someone', '/a', '/b'])
49 >>> bd.bug_from_uuid('a').assigned
51 >>> bd.bug_from_uuid('b').assigned
54 >>> ret = ui.run(cmd, args=['none', '/a'])
56 >>> bd.bug_from_uuid('a').assigned is None
63 def __init__(self, *args, **kwargs):
64 libbe.command.Command.__init__(self, *args, **kwargs)
66 libbe.command.Argument(
67 name='assigned', metavar='ASSIGNED', default=None,
68 completion_callback=libbe.command.util.complete_assigned),
69 libbe.command.Argument(
70 name='bug-id', metavar='BUG-ID', default=None,
72 completion_callback=libbe.command.util.complete_bug_id),
75 def _run(self, **params):
76 assigned = params['assigned']
77 if assigned == 'none':
80 assigned = self._get_user_id()
81 bugdir = self._get_bugdir()
82 for bug_id in params['bug-id']:
84 libbe.command.util.bug_comment_from_user_id(bugdir, bug_id)
85 if bug.assigned != assigned:
86 bug.assigned = assigned
91 Assign a person to fix a bug.
93 Assigneds should be the person's Bugs Everywhere identity, the same
94 string that appears in Creator fields.
96 Special assigned strings:
97 "-" assign the bug to yourself
98 "none" un-assigns the bug