summaryrefslogtreecommitdiffstats
path: root/lib/bb/__init__.py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2007-08-12 12:09:59 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2007-08-12 12:09:59 +0000
commitfbe8d7cfb3b01a5df6f9b297c23fe61b30f4b3f9 (patch)
tree209b90fcbae91b503b035e7941f1c2a149059e0d /lib/bb/__init__.py
parentdf14ebde92034f452d764552592d71eaea988232 (diff)
downloadbitbake-fbe8d7cfb3b01a5df6f9b297c23fe61b30f4b3f9.tar.gz
bb/__init__.py: Improve which function
Diffstat (limited to 'lib/bb/__init__.py')
-rw-r--r--lib/bb/__init__.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py
index 983999916..0e88ec18a 100644
--- a/lib/bb/__init__.py
+++ b/lib/bb/__init__.py
@@ -345,14 +345,20 @@ def encodeurl(decoded):
#######################################################################
def which(path, item, direction = 0):
- """Useful function for locating a file in a PATH"""
- found = ""
+ """
+ Locate a file in a PATH
+ """
+
+ paths = (path or "").split(':')
+ if direction != 0:
+ paths.reverse()
+
for p in (path or "").split(':'):
- if os.path.exists(os.path.join(p, item)):
- found = os.path.join(p, item)
- if direction == 0:
- break
- return found
+ next = os.path.join(p, item)
+ if os.path.exists(next):
+ return next
+
+ return ""
#######################################################################