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... --- libbe/bug.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index 14f3db0..b98067f 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -36,7 +36,7 @@ import utility # in order of increasing severity severity_level_def = ( - ("wishlist","A feature that could improve usefullness, but not a bug."), + ("wishlist","A feature that could improve usefulness, but not a bug."), ("minor","The standard bug level."), ("serious","A bug that requires workarounds."), ("critical","A bug that prevents some features from working at all."), -- 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. --- libbe/bug.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index b98067f..46f244f 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -34,8 +34,8 @@ import utility # Use a tuple of (category, description) tuples since we don't have # ordered dicts in Python yet http://www.python.org/dev/peps/pep-0372/ -# in order of increasing severity -severity_level_def = ( +# in order of increasing severity. (name, description) pairs +severity_def = ( ("wishlist","A feature that could improve usefulness, but not a bug."), ("minor","The standard bug level."), ("serious","A bug that requires workarounds."), @@ -58,11 +58,23 @@ inactive_status_def = ( ### Convert the description tuples to more useful formats -severity_values = tuple([val for val,description in severity_level_def]) -severity_description = dict(severity_level_def) +severity_values = () +severity_description = {} severity_index = {} -for i in range(len(severity_values)): - severity_index[severity_values[i]] = i +def load_severities(severity_def): + global severity_values + global severity_description + global severity_index + if type(severity_def[0]) == dict: + # Convert {"name": "X", "description": "Y"} severities to ("X","Y"). + # The dict form is loaded from the per-tree settings file. + severity_def = [(d["name"], d["description"]) for d in severity_def] + severity_values = tuple([val for val,description in severity_def]) + severity_description = dict(severity_def) + severity_index = {} + for i,severity in enumerate(severity_values): + severity_index[severity] = i +load_severities(severity_def) active_status_values = tuple(val for val,description in active_status_def) inactive_status_values = tuple(val for val,description in inactive_status_def) -- cgit From d1dfc45b051b0e14c0e2d7ed6dbf1d32927d7bfb Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 4 Dec 2008 10:32:10 -0500 Subject: bug severity verification now works with per-tree severities. I adjusted the YAML format following http://pyyaml.org/ticket/11 Unicode support To remove '!!python/unicode' escapes and allow unicode in the output. We can always have unicode in the output because the output is encoded (as per the BugFile.encoding setting) before being sent to the outside world. --- libbe/bug.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index 46f244f..2cd05e3 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -65,10 +65,6 @@ def load_severities(severity_def): global severity_values global severity_description global severity_index - if type(severity_def[0]) == dict: - # Convert {"name": "X", "description": "Y"} severities to ("X","Y"). - # The dict form is loaded from the per-tree settings file. - severity_def = [(d["name"], d["description"]) for d in severity_def] severity_values = tuple([val for val,description in severity_def]) severity_description = dict(severity_def) severity_index = {} @@ -125,7 +121,7 @@ class Bug(settings_object.SavedSettingsObject): @_versioned_property(name="severity", doc="A measure of the bug's importance", default="minor", - allowed=severity_values, + check_fn=lambda s: s in severity_values, require_save=True) def severity(): return {} -- 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. --- libbe/bug.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'libbe/bug.py') diff --git a/libbe/bug.py b/libbe/bug.py index 2cd05e3..f871c7a 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -52,8 +52,7 @@ active_status_def = ( inactive_status_def = ( ("closed", "The bug is no longer relevant."), ("fixed", "The bug should no longer occur."), - ("wontfix","It's not a bug, it's a feature."), - ("disabled", "?")) + ("wontfix","It's not a bug, it's a feature.")) ### Convert the description tuples to more useful formats @@ -65,6 +64,8 @@ def load_severities(severity_def): global severity_values global severity_description global severity_index + if severity_def == settings_object.EMPTY: + return severity_values = tuple([val for val,description in severity_def]) severity_description = dict(severity_def) severity_index = {} @@ -72,13 +73,29 @@ def load_severities(severity_def): severity_index[severity] = i load_severities(severity_def) -active_status_values = tuple(val for val,description in active_status_def) -inactive_status_values = tuple(val for val,description in inactive_status_def) -status_values = active_status_values + inactive_status_values -status_description = dict(active_status_def+inactive_status_def) +active_status_values = [] +inactive_status_values = [] +status_values = [] +status_description = {} status_index = {} -for i in range(len(status_values)): - status_index[status_values[i]] = i +def load_status(active_status_def, inactive_status_def): + global active_status_values + global inactive_status_values + global status_values + global status_description + global status_index + if active_status_def == settings_object.EMPTY: + active_status_def = globals()["active_status_def"] + if inactive_status_def == settings_object.EMPTY: + inactive_status_def = globals()["inactive_status_def"] + active_status_values = tuple([val for val,description in active_status_def]) + inactive_status_values = tuple([val for val,description in inactive_status_def]) + status_values = active_status_values + inactive_status_values + status_description = dict(tuple(active_status_def) + tuple(inactive_status_def)) + status_index = {} + for i,status in enumerate(status_values): + status_index[status] = i +load_status(active_status_def, inactive_status_def) class Bug(settings_object.SavedSettingsObject): @@ -128,7 +145,7 @@ class Bug(settings_object.SavedSettingsObject): @_versioned_property(name="status", doc="The bug's current status", default="open", - allowed=status_values, + check_fn=lambda s: s in status_values, require_save=True) def status(): return {} -- cgit