From a137e93fb63f88cf47b70ac5bba51a79df47bd41 Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Wed, 9 Mar 2005 17:25:46 +0000 Subject: [PATCH] Added basic bug-listing functionality --- .../f51dc5a7-37b7-4ce1-859a-b7cb58be6494/name | 1 + .../summary | 1 + .be/version | 1 + be | 30 +++++++ libbe/__init__.py | 0 libbe/__init__.pyc | Bin 0 -> 115 bytes libbe/cmdutil.py | 73 ++++++++++++++++++ libbe/cmdutil.pyc | Bin 0 -> 5107 bytes 8 files changed, 106 insertions(+) create mode 100644 .be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/name create mode 100644 .be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/summary create mode 100644 .be/version create mode 100755 be create mode 100644 libbe/__init__.py create mode 100644 libbe/__init__.pyc create mode 100644 libbe/cmdutil.py create mode 100644 libbe/cmdutil.pyc diff --git a/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/name b/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/name new file mode 100644 index 0000000..49529a8 --- /dev/null +++ b/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/name @@ -0,0 +1 @@ +abentley-1 diff --git a/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/summary b/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/summary new file mode 100644 index 0000000..1c2d1a3 --- /dev/null +++ b/.be/bugs/f51dc5a7-37b7-4ce1-859a-b7cb58be6494/summary @@ -0,0 +1 @@ +Can't create bugs diff --git a/.be/version b/.be/version new file mode 100644 index 0000000..25c1c63 --- /dev/null +++ b/.be/version @@ -0,0 +1 @@ +Bugs Everywhere Tree 0 0 diff --git a/be b/be new file mode 100755 index 0000000..f1e6cb3 --- /dev/null +++ b/be @@ -0,0 +1,30 @@ +#!/usr/bin/env python +"""Bugs Everywhere - Distributed bug tracking + +be list: list bugs +be status: view or set the status of a bug +be comment: append a comment to a bug +be set-root: assign the root directory for bug tracking +""" +from libbe.cmdutil import * +import sys + +def list_bugs(args): + bugs = list(tree_root(os.getcwd()).list()) + if len(bugs) == 0: + print "No bugs found" + for bug in bugs: + print "%s: %s" % (unique_name(bug, bugs), bug.summary) + + + + + +if len(sys.argv) == 1: + print __doc__ +else: + { + "list": list_bugs + }[sys.argv[1]](sys.argv[2:]) + + diff --git a/libbe/__init__.py b/libbe/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/libbe/__init__.pyc b/libbe/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c79880a0c505296a514c3644143334f11b93bc52 GIT binary patch literal 115 zcmcEi#LK0ms_&G{00oRd+5w1*S%5?e14FO|NW@PANHCxg#mYc2{fzwFRQ<%H)Vz|M j)JpxNRQ;UHBp?|dpP83g5+AQuP+1Hz!5(BlF^B*FsVNhd literal 0 HcmV?d00001 diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py new file mode 100644 index 0000000..6c5285a --- /dev/null +++ b/libbe/cmdutil.py @@ -0,0 +1,73 @@ +import os +import os.path + +class NoBugDir(Exception): + 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 unique_name(bug, bugs): + return bug.name + +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 _set_status(self, status): + assert status in ("open", "closed") + + 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/cmdutil.pyc b/libbe/cmdutil.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8515fb9105267cb365f42bd43cdf68c3c0d8883d GIT binary patch literal 5107 zcmbtYTW=dh6h5;~?5vwYXlTkss;o+-20_w3AR+Yunxuj!3z3S7NR?%KH^~Ou>+Y;c zEVVBL0Y8La$S>gg&g{jP7VMB{XJ=<;&hxi2N*a z>?TGhMnX?cj0B$iCUPb6({V+D3LlQwBv{kQx&-TTf@9TUQ&obRzN<;Fp_2^>d zZLf^%y!IsZB&x_OkyoBvd1A1Phqfx3k+4micy<;xf+z`lX`Dd9Hmh_RBhVrXc(pKw(hlI|D?&i#nS=_3L!e! zdzkH=#e;CK(+!7dKb-7!!@Yjg#n>AJ<235;jwUl)RH`aTn7Y|Aju(yEZVx+y5MtEz zVGsx7J|EpXCt}HZW&XL(Xb?+RR85a=qpn<2kNkxR+!q;%JX-(C2t0F{NV+cZxtQ!- zl|F*!;HK9mKd?bZ;z0Z^_W9X^`F?m8uEcIn&OM2@@UEUw{?*9P6f|$B-<99X+hU%l zn>k^}twL@fe-sdll(=Py$X%HFmoTyPCiU4kU? zoN`Xe&ysPdlk+$lDwmAINz@N5oflq4HnnyW(=@bcJC}gub4x2(kfdAnkP8~;ahjd% zsKPYyDN#yiFN-r`J59o{O=U>g?qCpe%T%OhZkugDZr$7j?Cv<{=KxUWGaTVyxZSxH z5V*oz9XG1MQ5Av9jM|^#x74^v*M5ix=w=&Fp~>XpEKI`2Glrt zo)b7Cu!ey(QVcsiuNRE&fGv$X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