aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2005-03-09 19:32:17 +0000
committerAaron Bentley <abentley@panoramicfeedback.com>2005-03-09 19:32:17 +0000
commit006b0cb118041cac8081032ad2d401fdd69fe6ae (patch)
treee8dd9b0d65d0ce3ca842cd279ba3edc724416e8e /libbe
parent6ade356915dc78cae448b8b48028659ee0528244 (diff)
downloadbugseverywhere-006b0cb118041cac8081032ad2d401fdd69fe6ae.tar.gz
Added ability to create, close, open bugs
Diffstat (limited to 'libbe')
-rw-r--r--libbe/bugdir.py24
-rw-r--r--libbe/cmdutil.py16
-rw-r--r--libbe/names.py22
3 files changed, 47 insertions, 15 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py
index efb392d..5e1d409 100644
--- a/libbe/bugdir.py
+++ b/libbe/bugdir.py
@@ -2,7 +2,7 @@ import os
import os.path
import cmdutil
import errno
-
+import names
class NoBugDir(cmdutil.UserError):
def __init__(self, path):
@@ -38,6 +38,13 @@ class BugDir:
continue
yield Bug(self.bugs_path, uuid)
+ def new_bug(self):
+ uuid = names.uuid()
+ path = os.path.join(self.bugs_path, uuid)
+ os.mkdir(path)
+ return Bug(self.bugs_path, uuid)
+
+
def file_property(name, valid=None):
def getter(self):
value = self._get_value(name)
@@ -68,23 +75,10 @@ class Bug(object):
summary = file_property("summary")
creator = file_property("creator")
target = file_property("target")
+ status = file_property("status", valid=("open", "closed"))
severity = file_property("severity", valid=("wishlist", "minor", "serious",
"critical", "fatal"))
- 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"
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index 4cc7d12..560c78d 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -4,3 +4,19 @@ def unique_name(bug, bugs):
class UserError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)
+
+def get_bug(spec, bug_dir):
+ bugs = list(bug_dir.list())
+ for bug in bugs:
+ if bug.uuid == spec:
+ return bug
+ matches = []
+ for bug in bugs:
+ if bug.name == spec:
+ matches.append(bug)
+ if len(matches) > 1:
+ raise UserError("More than one bug has the name %s. Please use the"
+ " uuid." % spec)
+ if len(matches) == 0:
+ raise UserError("No bug has the name %s" % spec)
+ return matches[0]
diff --git a/libbe/names.py b/libbe/names.py
new file mode 100644
index 0000000..a0c579b
--- /dev/null
+++ b/libbe/names.py
@@ -0,0 +1,22 @@
+import commands
+import os
+
+def uuid():
+ return commands.getoutput('uuidgen')
+
+def creator():
+ return os.environ["LOGNAME"]
+
+def friendly_name(bugs, ctor):
+ last = 0
+ for bug in bugs:
+ name = bug.name
+ if name is None:
+ continue
+ if name.startswith(ctor):
+ num = int(name.split("-")[-1])
+ if num > last:
+ last = num
+ return "%s-%i" % (ctor, num+1)
+
+