diff options
author | W. Trevor King <wking@drexel.edu> | 2008-12-04 12:42:22 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-12-04 12:42:22 -0500 |
commit | 30d707caba54c452dc33168536c8fa3c33ed47bd (patch) | |
tree | b1bb38c83342d10fcdf0b66bedbdcc1c389bad94 /becommands | |
parent | f6c5402f58b8450ee4e1a78da87b560491abbd45 (diff) | |
parent | 72f9263f3d812fb817e0bc4f5c7d07b60df2cd6c (diff) | |
download | bugseverywhere-30d707caba54c452dc33168536c8fa3c33ed47bd.tar.gz |
Merged in the successful per-tree-config branch.
Diffstat (limited to 'becommands')
-rw-r--r-- | becommands/list.py | 40 | ||||
-rw-r--r-- | becommands/merge.py | 2 | ||||
-rw-r--r-- | becommands/new.py | 14 | ||||
-rw-r--r-- | becommands/severity.py | 52 | ||||
-rw-r--r-- | becommands/show.py | 1 | ||||
-rw-r--r-- | becommands/status.py | 56 |
6 files changed, 110 insertions, 55 deletions
diff --git a/becommands/list.py b/becommands/list.py index ff340e3..8c69eaa 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -15,9 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """List bugs""" -from libbe import cmdutil, bugdir -from libbe.bug import cmp_full, severity_values, status_values, \ - active_status_values, inactive_status_values +from libbe import cmdutil, bugdir, bug import os __desc__ = __doc__ @@ -43,13 +41,13 @@ def execute(args, test=False): # select status if options.status != None: if options.status == "all": - status = status_values + status = bug.status_values else: status = options.status.split(',') else: status = [] if options.active == True: - status.extend(list(active_status_values)) + status.extend(list(bug.active_status_values)) if options.unconfirmed == True: status.append("unconfirmed") if options.open == True: @@ -57,11 +55,11 @@ def execute(args, test=False): if options.test == True: status.append("test") if status == []: # set the default value - status = active_status_values + status = bug.active_status_values # select severity if options.severity != None: if options.severity == "all": - severity = severity_values + severity = bug.severity_values else: severity = options.severity.split(',') else: @@ -69,10 +67,10 @@ def execute(args, test=False): if options.wishlist == True: severity.extend("wishlist") if options.important == True: - serious = severity_values.index("serious") - severity.append(list(severity_values[serious:])) + serious = bug.severity_values.index("serious") + severity.append(list(bug.severity_values[serious:])) if severity == []: # set the default value - severity = severity_values + severity = bug.severity_values # select assigned if options.assigned != None: if options.assigned == "all": @@ -117,15 +115,15 @@ def execute(args, test=False): print "No matching bugs found" def list_bugs(cur_bugs, title=None, just_uuids=False): - cur_bugs.sort(cmp_full) + cur_bugs.sort(bug.cmp_full) if len(cur_bugs) > 0: if title != None: print cmdutil.underlined(title) - for bug in cur_bugs: + for bg in cur_bugs: if just_uuids: - print bug.uuid + print bg.uuid else: - print bug.string(shortlist=True) + print bg.string(shortlist=True) list_bugs(bugs, just_uuids=options.uuids) @@ -158,7 +156,9 @@ def get_parser(): dest=attr, help=help) return parser -longhelp=""" + +def help(): + longhelp=""" This command lists bugs. Normally it prints a short string like 576:om: Allow attachments Where @@ -189,19 +189,17 @@ target In addition, there are some shortcut options that set boolean flags. The boolean options are ignored if the matching string option is used. -""" % (','.join(status_values), - ','.join(severity_values)) - -def help(): +""" % (','.join(bug.status_values), + ','.join(bug.severity_values)) return get_parser().help_str() + longhelp def complete(options, args, parser): for option, value in cmdutil.option_value_pairs(options, parser): if value == "--complete": if option == "status": - raise cmdutil.GetCompletions(status_values) + raise cmdutil.GetCompletions(bug.status_values) elif option == "severity": - raise cmdutil.GetCompletions(severity_values) + raise cmdutil.GetCompletions(bug.severity_values) raise cmdutil.GetCompletions() if "--complete" in args: raise cmdutil.GetCompletions() # no positional arguments for list diff --git a/becommands/merge.py b/becommands/merge.py index 9f324f7..927bb63 100644 --- a/becommands/merge.py +++ b/becommands/merge.py @@ -52,6 +52,7 @@ def execute(args, test=False): Status : open Assigned : Target : + Reporter : Creator : John Doe <jdoe@example.com> Created : Wed, 31 Dec 1969 19:00 (Thu, 01 Jan 1970 00:00:00 +0000) Bug A @@ -96,6 +97,7 @@ def execute(args, test=False): Status : closed Assigned : Target : + Reporter : Creator : Jane Doe <jdoe@example.com> Created : Wed, 31 Dec 1969 19:00 (Thu, 01 Jan 1970 00:00:00 +0000) Bug B diff --git a/becommands/new.py b/becommands/new.py index dec40cb..1c5246c 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -29,12 +29,12 @@ def execute(args, test=False): Created bug with ID X >>> bd.load() >>> bug = bd.bug_from_uuid("X") - >>> bug.summary - u'this is a test' + >>> print bug.summary + this is a test >>> bug.time <= int(time.time()) True - >>> bug.severity - u'minor' + >>> print bug.severity + minor >>> bug.target == settings_object.EMPTY True """ @@ -49,6 +49,10 @@ def execute(args, test=False): bug.reporter = options.reporter else: bug.reporter = bug.creator + if options.assigned != None: + bug.assigned = options.assigned + elif bd.default_assignee != settings_object.EMPTY: + bug.assigned = bd.default_assignee bd.save() print "Created bug with ID %s" % bd.bug_shortname(bug) @@ -56,6 +60,8 @@ def get_parser(): parser = cmdutil.CmdOptionParser("be new SUMMARY") parser.add_option("-r", "--reporter", metavar="REPORTER", dest="reporter", help="The user who reported the bug", default=None) + parser.add_option("-a", "--assigned", metavar="ASSIGNED", dest="assigned", + help="The developer in charge of the bug", default=None) return parser longhelp=""" diff --git a/becommands/severity.py b/becommands/severity.py index 7b7ee29..5d27222 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -15,8 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show or change a bug's severity level""" -from libbe import cmdutil, bugdir -from libbe.bug import severity_values, severity_description +from libbe import cmdutil, bugdir, bug __desc__ = __doc__ def execute(args, test=False): @@ -35,8 +34,7 @@ def execute(args, test=False): """ parser = get_parser() options, args = parser.parse_args(args) - cmdutil.default_complete(options, args, parser, - bugid_args={0: lambda bug : bug.active==True}) + complete(options, args, parser) if len(args) not in (1,2): raise cmdutil.UsageError bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) @@ -56,7 +54,8 @@ def get_parser(): parser = cmdutil.CmdOptionParser("be severity BUG-ID [SEVERITY]") return parser -longhelp=[""" +def help(): + longhelp=[""" Show or change a bug's severity level. If no severity is specified, the current value is printed. If a severity level @@ -64,13 +63,38 @@ is specified, it will be assigned to the bug. Severity levels are: """] -longest_severity_len = max([len(s) for s in severity_values]) -for severity in severity_values : - description = severity_description[severity] - s = "%*s : %s\n" % (longest_severity_len, severity, description) - longhelp.append(s) -longhelp = ''.join(longhelp) - - -def help(): + try: # See if there are any per-tree severity configurations + bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) + except bugdir.NoBugDir, e: + pass # No tree, just show the defaults + longest_severity_len = max([len(s) for s in bug.severity_values]) + for severity in bug.severity_values : + description = bug.severity_description[severity] + s = "%*s : %s\n" % (longest_severity_len, severity, description) + longhelp.append(s) + longhelp = ''.join(longhelp) return get_parser().help_str() + longhelp + +def complete(options, args, parser): + for option,value in cmdutil.option_value_pairs(options, parser): + if value == "--complete": + # no argument-options at the moment, so this is future-proofing + raise cmdutil.GetCompletions() + for pos,value in enumerate(args): + if value == "--complete": + try: # See if there are any per-tree severity configurations + bd = bugdir.BugDir(from_disk=True, + manipulate_encodings=False) + except bugdir.NoBugDir: + bd = None + if pos == 0: # fist positional argument is a bug id + ids = [] + if bd != None: + bd.load_all_bugs() + filter = lambda bg : bg.active==True + bugs = [bg for bg in bd if filter(bg)==True] + ids = [bd.bug_shortname(bg) for bg in bugs] + raise cmdutil.GetCompletions(ids) + elif pos == 1: # second positional argument is a severity + raise cmdutil.GetCompletions(bug.severity_values) + raise cmdutil.GetCompletions() diff --git a/becommands/show.py b/becommands/show.py index 37168c1..87b890f 100644 --- a/becommands/show.py +++ b/becommands/show.py @@ -30,6 +30,7 @@ def execute(args, test=False): Status : open Assigned : Target : + Reporter : Creator : John Doe <jdoe@example.com> Created : Wed, 31 Dec 1969 19:00 (Thu, 01 Jan 1970 00:00:00 +0000) Bug A diff --git a/becommands/status.py b/becommands/status.py index 5ff824e..40e9b51 100644 --- a/becommands/status.py +++ b/becommands/status.py @@ -15,8 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Show or change a bug's status""" -from libbe import cmdutil, bugdir -from libbe.bug import status_values, status_description +from libbe import cmdutil, bugdir, bug __desc__ = __doc__ def execute(args, test=False): @@ -35,8 +34,7 @@ def execute(args, test=False): """ parser = get_parser() options, args = parser.parse_args(args) - cmdutil.default_complete(options, args, parser, - bugid_args={0: lambda bug : True}) + complete(options, args, parser) if len(args) not in (1,2): raise cmdutil.UsageError bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test) @@ -56,20 +54,46 @@ def get_parser(): parser = cmdutil.CmdOptionParser("be status BUG-ID [STATUS]") return parser -longhelp=[""" -Show or change a bug's severity level. -If no severity is specified, the current value is printed. If a severity level +def help(): + longhelp=[""" +Show or change a bug's status. + +If no status is specified, the current value is printed. If a status is specified, it will be assigned to the bug. -Severity levels are: +Status levels are: """] -longest_status_len = max([len(s) for s in status_values]) -for status in status_values : - description = status_description[status] - s = "%*s : %s\n" % (longest_status_len, status, description) - longhelp.append(s) -longhelp = ''.join(longhelp) - -def help(): + try: # See if there are any per-tree status configurations + bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) + except bugdir.NoBugDir, e: + pass # No tree, just show the defaults + longest_status_len = max([len(s) for s in bug.status_values]) + for status in bug.status_values : + description = bug.status_description[status] + s = "%*s : %s\n" % (longest_status_len, status, description) + longhelp.append(s) + longhelp = ''.join(longhelp) return get_parser().help_str() + longhelp + +def complete(options, args, parser): + for option,value in cmdutil.option_value_pairs(options, parser): + if value == "--complete": + # no argument-options at the moment, so this is future-proofing + raise cmdutil.GetCompletions() + for pos,value in enumerate(args): + if value == "--complete": + try: # See if there are any per-tree status configurations + bd = bugdir.BugDir(from_disk=True, + manipulate_encodings=False) + except bugdir.NoBugDir: + bd = None + if pos == 0: # fist positional argument is a bug id + ids = [] + if bd != None: + bd.load_all_bugs() + ids = [bd.bug_shortname(bg) for bg in bd] + raise cmdutil.GetCompletions(ids) + elif pos == 1: # second positional argument is a status + raise cmdutil.GetCompletions(bug.status_values) + raise cmdutil.GetCompletions() |