Added support for severity, creator, target
authorAaron Bentley <abentley@panoramicfeedback.com>
Wed, 9 Mar 2005 18:25:15 +0000 (18:25 +0000)
committerAaron Bentley <abentley@panoramicfeedback.com>
Wed, 9 Mar 2005 18:25:15 +0000 (18:25 +0000)
be
libbe/bugdir.py
libbe/bugdir.pyc

diff --git a/be b/be
index a93617ac9bd39ff055cf38127c01831378b9198e..11e8c5cb3c2a896b0906121f384ea453daf36457 100755 (executable)
--- a/be
+++ b/be
@@ -12,11 +12,27 @@ import sys
 import os
 
 def list_bugs(args):
-    bugs = [b for b in tree_root(os.getcwd()).list() if b.active]
+    active = True
+    status = ("minor", "serious", "critical", "fatal")
+    def filter(bug):
+        if active is not None:
+            if bug.active != active:
+                return False
+        if bug.status not in status:
+            return False
+        return True
+        
+    bugs = [b for b in tree_root(os.getcwd()).list() ]
     if len(bugs) == 0:
         print "No matching bugs found"
     for bug in bugs:
-        print "%s: %s" % (unique_name(bug, bugs), bug.summary)
+        target = bug.target
+        if target is None:
+            target = ""
+        else:
+            target = " target: %s" % target
+        print "id: %s severity: %s%s\n%s\n" % (unique_name(bug, bugs), 
+                                             bug.severity, target, bug.summary)
 
     
 
index de3e55064476fab4753ca16ae96b378e777837db..efb392d205f524bd33182b58421bb077ca02d82d 100644 (file)
@@ -1,6 +1,8 @@
 import os
 import os.path
 import cmdutil
+import errno
+
 
 class NoBugDir(cmdutil.UserError):
     def __init__(self, path):
@@ -36,10 +38,15 @@ class BugDir:
                 continue
             yield Bug(self.bugs_path, uuid)
 
-def file_property(name):
+def file_property(name, valid=None):
     def getter(self):
-        return self._get_value(name)
+        value = self._get_value(name) 
+        if valid is not None:
+            assert value in valid
+        return value
     def setter(self, value):
+        if valid is not None:
+            assert value in valid
         return self._set_value(name, value)
     return property(getter, setter)
 
@@ -59,6 +66,10 @@ class Bug(object):
     
     name = file_property("name")
     summary = file_property("summary")
+    creator = file_property("creator")
+    target = file_property("target")
+    severity = file_property("severity", valid=("wishlist", "minor", "serious",
+                                                "critical", "fatal"))
 
     def _check_status(status):
         assert status in ("open", "closed")
@@ -80,8 +91,14 @@ class Bug(object):
     active = property(_get_active)
 
     def _get_value(self, name):
-        return file(self.get_path(name), "rb").read().rstrip("\n")
+        try:
+            return file(self.get_path(name), "rb").read().rstrip("\n")
+        except IOError, e:
+            if e.errno == errno.EEXIST:
+                return None
 
     def _set_value(self, name, value):
+        if value is None:
+            os.unlink(self.get_path(name))
         file(self.get_path(name), "wb").write("%s\n" % value)
 
index 12480901ab9852ab9f9e9c00c4be01f462e95606..3d8dfc6897403ecd90999c47b151888ceb8b2c49 100644 (file)
Binary files a/libbe/bugdir.pyc and b/libbe/bugdir.pyc differ