From 83e320a61eb74dab6eddfdda010f34fa42eedc0c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 09:14:01 -0500 Subject: Added per-tree configurable severities. They currently have no effect, but you can see them with $ be set There's a lot of information in this one 'settings' variable. I think set will have to be specialized to handle arrays smoothly... --- becommands/merge.py | 2 ++ becommands/new.py | 8 ++++---- becommands/show.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'becommands') 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 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 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..15ee4a9 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 """ 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 Created : Wed, 31 Dec 1969 19:00 (Thu, 01 Jan 1970 00:00:00 +0000) Bug A -- cgit From ca347e86bef7bbdd0d1007beaf283f29ec1bbdff Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 09:54:39 -0500 Subject: Per-tree settings now passed into bug module. becommands/severity gets the configured settings appropriately. Todo: adjust setting-validation to compare against the current values. setup becommands/severity to --complete severities. --- becommands/severity.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'becommands') diff --git a/becommands/severity.py b/becommands/severity.py index 7b7ee29..92f31e8 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): @@ -56,7 +55,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 +64,14 @@ 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: + bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) + except bugdir.NoBugDir, e: + pass + 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 -- cgit From 6af76d83e10bd59ceb4aa706c0c30960fbe6f476 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 10:40:24 -0500 Subject: Adjusted becommands/list.py to use current bug severities levels. --- becommands/list.py | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'becommands') 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 -- cgit From b5b8d7214b24338ba5c97287810a4a67e61c3c06 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 11:32:57 -0500 Subject: Per-tree status levels working. --- becommands/severity.py | 4 ++-- becommands/status.py | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'becommands') diff --git a/becommands/severity.py b/becommands/severity.py index 92f31e8..c44d8ed 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -64,10 +64,10 @@ is specified, it will be assigned to the bug. Severity levels are: """] - try: + try: # See if there are any per-tree severity configurations bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) except bugdir.NoBugDir, e: - pass + 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] diff --git a/becommands/status.py b/becommands/status.py index 5ff824e..b781a2a 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): @@ -56,7 +55,9 @@ def get_parser(): parser = cmdutil.CmdOptionParser("be status BUG-ID [STATUS]") 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,12 +65,14 @@ is specified, it will be assigned to the bug. Severity 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 -- cgit From 2447b5df014630d402f1fe28db6898a981f5ada0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 11:56:34 -0500 Subject: becommands/severity and status now handle --complete appropriately. I also disabled interspersed options and arguments in cmdutils.CmdOptionParser. See http://docs.python.org/library/optparse.html Now $ be severity xyz --complete returns available severities. It had previously returned --help --complete --- becommands/severity.py | 27 +++++++++++++++++++++++++-- becommands/status.py | 31 ++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 7 deletions(-) (limited to 'becommands') diff --git a/becommands/severity.py b/becommands/severity.py index c44d8ed..5d27222 100644 --- a/becommands/severity.py +++ b/becommands/severity.py @@ -34,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) @@ -75,3 +74,27 @@ Severity levels are: 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/status.py b/becommands/status.py index b781a2a..40e9b51 100644 --- a/becommands/status.py +++ b/becommands/status.py @@ -34,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) @@ -58,12 +57,12 @@ def get_parser(): def help(): longhelp=[""" -Show or change a bug's severity level. +Show or change a bug's status. -If no severity is specified, the current value is printed. If a severity level +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: """] try: # See if there are any per-tree status configurations bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) @@ -76,3 +75,25 @@ Severity levels are: 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() -- cgit From 72f9263f3d812fb817e0bc4f5c7d07b60df2cd6c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 12:40:39 -0500 Subject: Added per-tree default assignee option. The new setting is currently only used when creating new bugs with becommand/new. --- becommands/new.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'becommands') diff --git a/becommands/new.py b/becommands/new.py index 15ee4a9..1c5246c 100644 --- a/becommands/new.py +++ b/becommands/new.py @@ -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=""" -- cgit