Reported bug with utf-8 strings
[be.git] / becommands / open.py
1 # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
2 #                         Marien Zwart <marienz@gentoo.org>
3 #                         Thomas Gerigk <tgerigk@gmx.de>
4 #                         W. Trevor King <wking@drexel.edu>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 """Re-open a bug"""
20 from libbe import cmdutil, bugdir
21 __desc__ = __doc__
22
23 def execute(args, manipulate_encodings=True):
24     """
25     >>> import os
26     >>> bd = bugdir.SimpleBugDir()
27     >>> os.chdir(bd.root)
28     >>> print bd.bug_from_shortname("b").status
29     closed
30     >>> execute(["b"], manipulate_encodings=False)
31     >>> bd._clear_bugs()
32     >>> print bd.bug_from_shortname("b").status
33     open
34     >>> bd.cleanup()
35     """
36     parser = get_parser()
37     options, args = parser.parse_args(args)
38     cmdutil.default_complete(options, args, parser,
39                              bugid_args={0: lambda bug : bug.active==False})
40     if len(args) == 0:
41         raise cmdutil.UsageError, "Please specify a bug id."
42     if len(args) > 1:
43         raise cmdutil.UsageError, "Too many arguments."
44     bd = bugdir.BugDir(from_disk=True,
45                        manipulate_encodings=manipulate_encodings)
46     bug = cmdutil.bug_from_shortname(bd, args[0])
47     bug.status = "open"
48
49 def get_parser():
50     parser = cmdutil.CmdOptionParser("be open BUG-ID")
51     return parser
52
53 longhelp="""
54 Mark a bug as 'open'.
55 """
56
57 def help():
58     return get_parser().help_str() + longhelp