From 913e78898e65e1d95c6313e86854cdc2ab9e35aa Mon Sep 17 00:00:00 2001 From: Holger Freyther Date: Sun, 17 May 2009 06:19:39 +0200 Subject: bitbake: [parse] Unify opening a file... Signed-off-by: Richard Purdie --- bitbake/lib/bb/parse/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'bitbake/lib/bb/parse/__init__.py') diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py index 5dd96c4136..c6a925c7a8 100644 --- a/bitbake/lib/bb/parse/__init__.py +++ b/bitbake/lib/bb/parse/__init__.py @@ -80,5 +80,24 @@ def init(fn, data): if h['supports'](fn): return h['init'](data) +def resolve_file(fn, d): + if not os.path.isabs(fn): + f = None + bbpath = (bb.data.getVar('BBPATH', d, 1) or '').split(':') + for p in bbpath: + j = os.path.join(p, fn) + if os.access(j, os.R_OK): + abs_fn = j + f = open(j, 'r') + break + if f is None: + raise IOError("file %s not found" % fn) + else: + f = open(fn,'r') + abs_fn = fn + + bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % abs_fn) + return (f, abs_fn) + from parse_py import __version__, ConfHandler, BBHandler -- cgit v1.2.3-54-g00ecf