From b2b03a3d1f06e7dba218eccbac0d045cad0a276e Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Wed, 9 Mar 2005 17:50:09 +0000 Subject: [PATCH] Implemented bug status and "active" flag --- .../status | 1 + be | 4 +- libbe/bugdir.py | 87 ++++++++++++++++++ libbe/bugdir.pyc | Bin 0 -> 5737 bytes 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 .be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/status create mode 100644 libbe/bugdir.py create mode 100644 libbe/bugdir.pyc 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 diff --git a/be b/be index e87ed0b..a93617a 100755 --- a/be +++ b/be @@ -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 new file mode 100644 index 0000000000000000000000000000000000000000..12480901ab9852ab9f9e9c00c4be01f462e95606 GIT binary patch literal 5737 zcmbtY?QRoC6rEYecI+4uNTEOxGN=f*QWL65NL7DO5~%v8R>enAEmbRLcav;zykTce z5()k^sO<~%4f=$Af}V3{zr0RLEE4T_c6a8^z4zRE=FWci?}hf~57sw4mHyT6`#mo6 z7LBjeE2RduqqB~q29ENz3LF*I)V5Z>quwiZqSUX01?AUxGpH+nK{^fP*VQ&eH1a`B zneP@Y=*>?xDf3w_06&=cq)qhm~&~b>b+E$GCCD)>MS)VaD^_pzDWm;3ZLf+`V(x z-0AKPO?Mo1wBS7$&=htL~c})57nQBQH2e!e}hkxNbNO6W5ioCKzq^ zI5xkV5kV!CH0CyX>$}l@us+-h#>pr+Uf&AVN8uJ)XahCZ4vwc5X;3s9rQ3Q%+okAJ z*BuY{186}vyY7DEPe#18@2rN!%JVLtAtpW{5Do1SG+Ig*2_FB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