aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2005-03-18 15:14:25 +0000
committerAaron Bentley <abentley@panoramicfeedback.com>2005-03-18 15:14:25 +0000
commitd7d616e4f8b885f55f8052e5eb22f3cec7ddbee4 (patch)
treee9441bf413985b6e24a5a2aede498d639c7128ef /libbe
parent90e118fac5cfb345e10487039a375c8af5835ddf (diff)
downloadbugseverywhere-d7d616e4f8b885f55f8052e5eb22f3cec7ddbee4.tar.gz
Used cmdutil tree_root wrapper to avoid tracebacks on wrong tree
Diffstat (limited to 'libbe')
-rw-r--r--libbe/cmdutil.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index ab0e8be..b550eb0 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -1,5 +1,7 @@
import bugdir
import plugin
+import os
+
def unique_name(bug, bugs):
chars = 1
for some_bug in bugs:
@@ -90,6 +92,27 @@ def underlined(instring):
return "%s\n%s" % (instring, "="*len(instring))
+
+def bug_tree(dir=None):
+ """Retrieve the bug tree specified by the user. If no directory is
+ specified, the current working directory is used.
+
+ :param dir: The directory to search for the bug tree in.
+
+ >>> bug_tree() is not None
+ True
+ >>> bug_tree("/")
+ Traceback (most recent call last):
+ UserErrorWrap: The directory "/" has no bug directory.
+ """
+ if dir is None:
+ dir = os.getcwd()
+ try:
+ return bugdir.tree_root(dir)
+ except bugdir.NoBugDir, e:
+ raise UserErrorWrap(e)
+
+
def _test():
import doctest
import sys