From d7d616e4f8b885f55f8052e5eb22f3cec7ddbee4 Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Fri, 18 Mar 2005 15:14:25 +0000 Subject: Used cmdutil tree_root wrapper to avoid tracebacks on wrong tree --- libbe/cmdutil.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libbe') 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 -- cgit