diff options
author | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-18 18:53:49 +0000 |
---|---|---|
committer | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-18 18:53:49 +0000 |
commit | 284b8f7226dda8b7bf35ac60ff80810a44d06eba (patch) | |
tree | afcd029e075b8346ff71b0d2c1f05eecde2d308b /libbe/bugdir.py | |
parent | d7d616e4f8b885f55f8052e5eb22f3cec7ddbee4 (diff) | |
download | bugseverywhere-284b8f7226dda8b7bf35ac60ff80810a44d06eba.tar.gz |
Implemented sorting by severity level
Diffstat (limited to 'libbe/bugdir.py')
-rw-r--r-- | libbe/bugdir.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py index addefe0..e1c95c5 100644 --- a/libbe/bugdir.py +++ b/libbe/bugdir.py @@ -94,6 +94,11 @@ def checked_property(name, valid): return self.__setattr__("_"+name, value) return property(getter, setter) +severity_levels = ("wishlist", "minor", "serious", "critical", "fatal") + +severity_value = {} +for i in range(len(severity_levels)): + severity_value[severity_levels[i]] = i class Bug(object): status = checked_property("status", (None, "open", "closed")) @@ -141,3 +146,25 @@ class Bug(object): rcs.add_id(path) output = file(path, "wb") mapfile.generate(output, map) + +class MockBug: + def __init__(self, severity): + self.severity = severity + +def cmp_severity(bug_1, bug_2): + """ + Compare the severity levels of two bugs, with more sever bugs comparing + as less. + + >>> cmp_severity(MockBug(None), MockBug(None)) + 0 + >>> cmp_severity(MockBug("wishlist"), MockBug(None)) < 0 + True + >>> cmp_severity(MockBug(None), MockBug("wishlist")) > 0 + True + >>> cmp_severity(MockBug("critical"), MockBug("wishlist")) < 0 + True + """ + val_1 = severity_value.get(bug_1.severity) + val_2 = severity_value.get(bug_2.severity) + return -cmp(val_1, val_2) |