summaryrefslogtreecommitdiffstats
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
commitd12e8d30d80a6a8d359088372ac3a1f74d355311 (patch)
treea07f6b665834bad0741dfb56e24922569660b835
parented1ad9242877840e2aaccc7dbca53e49e310a202 (diff)
downloadbitbake-d12e8d30d80a6a8d359088372ac3a1f74d355311.tar.gz
bb/__init__.py: Improve which function
-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 e601eda46..1bfecc49e 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 ""
#######################################################################