diff options
author | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-11 17:45:05 +0000 |
---|---|---|
committer | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-11 17:45:05 +0000 |
commit | f5458611072ab7c6048311430771d1ec297d4f61 (patch) | |
tree | 0f3c8787b0063a6d78a347e6b3f5276f3a5f4513 | |
parent | 56c2c54ef00acc75f2bce8ded2b7fa66e8d07712 (diff) | |
download | bugseverywhere-f5458611072ab7c6048311430771d1ec297d4f61.tar.gz |
Added severity command
-rwxr-xr-x | be | 18 | ||||
-rw-r--r-- | commands/__init__.py | 0 | ||||
-rw-r--r-- | commands/severity.py | 38 | ||||
-rw-r--r-- | libbe/bugdir.py | 15 | ||||
-rw-r--r-- | libbe/cmdutil.py | 13 |
5 files changed, 72 insertions, 12 deletions
@@ -1,5 +1,12 @@ #!/usr/bin/env python -"""Bugs Everywhere - Distributed bug tracking +from libbe.cmdutil import * +from libbe.bugdir import tree_root, create_bug_dir +from libbe import names +import sys +import os +import commands +import commands.severity +__doc__ = """Bugs Everywhere - Distributed bug tracking Supported commands set-root: assign the root directory for bug tracking @@ -8,15 +15,11 @@ Supported commands show: show a particular bug close: close a bug open: re-open a bug + severity: %s Unimplemented commands comment: append a comment to a bug -""" -from libbe.cmdutil import * -from libbe.bugdir import tree_root, create_bug_dir -from libbe import names -import sys -import os +""" % commands.severity.__desc__ def list_bugs(args): active = True @@ -77,6 +80,7 @@ else: "new": new_bug, "close": close_bug, "open": open_bug, + "severity": commands.severity.execute, }[sys.argv[1]] except KeyError, e: raise UserError("Unknown command \"%s\"" % e.args[0]) diff --git a/commands/__init__.py b/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/commands/__init__.py diff --git a/commands/severity.py b/commands/severity.py new file mode 100644 index 0000000..7a5051a --- /dev/null +++ b/commands/severity.py @@ -0,0 +1,38 @@ +"""Show or change a bug's severity level""" +from libbe.bugdir import tree_root +from libbe.cmdutil import get_bug +from libbe import bugdir +from libbe import cmdutil +__desc__ = __doc__ +def execute(args): + assert(len(args) in (0, 1, 2)) + if len(args) == 0: + print help() + return + bug = get_bug(args[0]) + if len(args) == 1: + print bug.severity + elif len(args) == 2: + try: + bug.severity = args[1] + except bugdir.InvalidValue, e: + if e.name != "severity": + raise + raise cmdutil.UserError ("Invalid severity level: %s" % e.value) + + +def help(): + return """be severity bug-id [severity] + +Show or change a bug's severity level. + +If no severity is specified, the current value is printed. If a severity level +is specified, it will be assigned to the bug. + +Severity levels are: +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. + fatal: A bug that makes the package unusable. +""" diff --git a/libbe/bugdir.py b/libbe/bugdir.py index 0008be8..4a79584 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -5,7 +5,7 @@ import errno import names import rcs -class NoBugDir(cmdutil.UserError): +class NoBugDir(Exception): def __init__(self, path): msg = "The directory \"%s\" has no bug directory." % path Exception.__init__(self, msg) @@ -53,17 +53,24 @@ class BugDir: path = os.path.join(self.bugs_path, uuid) rcs.mkdir(path) return Bug(self.bugs_path, uuid) - +class InvalidValue(Exception): + def __init__(self, name, value): + msg = "Cannot assign value %s to %s" % (value, name) + Exception.__init__(self, msg) + self.name = name + self.value = value def file_property(name, valid=None): def getter(self): value = self._get_value(name) if valid is not None: - assert value in valid + if value not in valid: + raise InvalidValue(name, value) return value def setter(self, value): if valid is not None: - assert value in valid + if value not in valid: + raise InvalidValue(name, value) return self._set_value(name, value) return property(getter, setter) diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py index ac67f3a..2afd53c 100644 --- a/libbe/cmdutil.py +++ b/libbe/cmdutil.py @@ -1,3 +1,4 @@ +import bugdir def unique_name(bug, bugs): chars = 1 for some_bug in bugs: @@ -11,8 +12,18 @@ class UserError(Exception): def __init__(self, msg): Exception.__init__(self, msg) -def get_bug(spec, bug_dir): +class UserErrorWrap(UserError): + def __init__(self, exception): + UserError.__init__(self, str(exception)) + self.exception = exception + +def get_bug(spec, bug_dir=None): matches = [] + try: + if bug_dir is None: + bug_dir = bugdir.tree_root('.') + except bugdir.NoBugDir, e: + raise UserErrorWrap(e) bugs = list(bug_dir.list()) for bug in bugs: if bug.uuid.startswith(spec): |