From ce800d3aea333919302a490838906983c18fe54d Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 12 Aug 2007 23:06:49 +0000 Subject: bitbake: Sync with upstream 1.8 branch for fixes git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2484 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- bitbake/lib/bb/__init__.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/bb/__init__.py') diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py index e601eda469..1bfecc49ec 100644 --- a/bitbake/lib/bb/__init__.py +++ b/bitbake/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 "" ####################################################################### -- cgit v1.2.3-54-g00ecf