diff options
author | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-09 17:50:09 +0000 |
---|---|---|
committer | Aaron Bentley <abentley@panoramicfeedback.com> | 2005-03-09 17:50:09 +0000 |
commit | b2b03a3d1f06e7dba218eccbac0d045cad0a276e (patch) | |
tree | 6ccf8c54f1f8a74f5bdf127b92d81af9179f8b25 | |
parent | 8d6a6a2af58408c4066b753f28d5b13ae6ee587a (diff) | |
download | bugseverywhere-b2b03a3d1f06e7dba218eccbac0d045cad0a276e.tar.gz |
Implemented bug status and "active" flag
-rw-r--r-- | .be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/status | 1 | ||||
-rwxr-xr-x | be | 4 | ||||
-rw-r--r-- | libbe/bugdir.py | 87 | ||||
-rw-r--r-- | libbe/bugdir.pyc | bin | 0 -> 5737 bytes |
4 files changed, 90 insertions, 2 deletions
diff --git a/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/status b/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/status new file mode 100644 index 0000000..f510327 --- /dev/null +++ b/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/status @@ -0,0 +1 @@ +open @@ -12,9 +12,9 @@ import sys import os def list_bugs(args): - bugs = list(tree_root(os.getcwd()).list()) + bugs = [b for b in tree_root(os.getcwd()).list() if b.active] if len(bugs) == 0: - print "No bugs found" + print "No matching bugs found" for bug in bugs: print "%s: %s" % (unique_name(bug, bugs), bug.summary) diff --git a/libbe/bugdir.py b/libbe/bugdir.py new file mode 100644 index 0000000..de3e550 --- /dev/null +++ b/libbe/bugdir.py @@ -0,0 +1,87 @@ +import os +import os.path +import cmdutil + +class NoBugDir(cmdutil.UserError): + def __init__(self, path): + msg = "The directory \"%s\" has no bug directory." % path + Exception.__init__(self, msg) + self.path = path + + +def tree_root(dir): + rootdir = os.path.realpath(dir) + while (True): + versionfile=os.path.join(rootdir, ".be/version") + if os.path.exists(versionfile): + test_version(versionfile) + break; + elif rootdir == "/": + raise NoBugDir(dir) + rootdir=os.path.dirname(rootdir) + return BugDir(os.path.join(rootdir, ".be")) + +def test_version(path): + assert (file(path, "rb").read() == "Bugs Everywhere Tree 0 0\n") + +class BugDir: + def __init__(self, dir): + self.dir = dir + self.bugs_path = os.path.join(self.dir, "bugs") + + + def list(self): + for uuid in os.listdir(self.bugs_path): + if (uuid.startswith('.')): + continue + yield Bug(self.bugs_path, uuid) + +def file_property(name): + def getter(self): + return self._get_value(name) + def setter(self, value): + return self._set_value(name, value) + return property(getter, setter) + +class Bug(object): + def __init__(self, path, uuid): + self.path = os.path.join(path, uuid) + self.uuid = uuid + + def get_path(self, file): + return os.path.join(self.path, file) + + def _get_name(self): + return self._get_value("name") + + def _set_name(self, value): + return self._set_value("name", value) + + name = file_property("name") + summary = file_property("summary") + + def _check_status(status): + assert status in ("open", "closed") + + def _set_status(self, status): + self._check_status(status) + self._set_value("status", status) + + def _get_status(self): + status = self._get_value("status") + assert status in ("open", "closed") + return status + + status = property(_get_status, _set_status) + + def _get_active(self): + return self.status == "open" + + active = property(_get_active) + + def _get_value(self, name): + return file(self.get_path(name), "rb").read().rstrip("\n") + + def _set_value(self, name, value): + file(self.get_path(name), "wb").write("%s\n" % value) + diff --git a/libbe/bugdir.pyc b/libbe/bugdir.pyc Binary files differnew file mode 100644 index 0000000..1248090 --- /dev/null +++ b/libbe/bugdir.pyc |