diff options
author | 2007-08-12 12:09:59 +0000 | |
---|---|---|
committer | 2007-08-12 12:09:59 +0000 | |
commit | fbe8d7cfb3b01a5df6f9b297c23fe61b30f4b3f9 (patch) | |
tree | 209b90fcbae91b503b035e7941f1c2a149059e0d /lib/bb/__init__.py | |
parent | df14ebde92034f452d764552592d71eaea988232 (diff) | |
download | bitbake-fbe8d7cfb3b01a5df6f9b297c23fe61b30f4b3f9.tar.gz |
bb/__init__.py: Improve which function
Diffstat (limited to 'lib/bb/__init__.py')
-rw-r--r-- | lib/bb/__init__.py | 20 |
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 "" ####################################################################### |