diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 33 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 14 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/__init__.py | 8 |
3 files changed, 27 insertions, 28 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 262c883c9..bb5617488 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -11,7 +11,7 @@ # Copyright (C) 2003, 2004 Chris Larson # Copyright (C) 2003, 2004 Phil Blundell -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. @@ -25,15 +25,17 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import re, bb, os, sys, time, string +from __future__ import absolute_import +import re, bb, os import bb.fetch, bb.build, bb.utils -from bb import data, fetch +from bb import data -from ConfHandler import include, init -from bb.parse import ParseError, resolve_file, ast +from . import ConfHandler +from .. import resolve_file, ast +from .ConfHandler import include, init # For compatibility -from bb.parse import vars_from_file +bb.deprecate_import(__name__, "bb.parse", ["vars_from_file"]) __func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" ) __inherit_regexp__ = re.compile( r"inherit\s+(.+)" ) @@ -68,8 +70,8 @@ def inherit(files, d): __inherit_cache = data.getVar('__inherit_cache', d) or [] fn = "" lineno = 0 - files = data.expand(files, d) for file in files: + file = data.expand(file, d) if file[0] != "/" and file[-8:] != ".bbclass": file = os.path.join('classes', '%s.bbclass' % file) @@ -80,17 +82,17 @@ def inherit(files, d): include(fn, file, d, "inherit") __inherit_cache = data.getVar('__inherit_cache', d) or [] -def get_statements(filename, absolsute_filename, base_name): +def get_statements(filename, absolute_filename, base_name): global cached_statements try: - return cached_statements[absolsute_filename] + return cached_statements[absolute_filename] except KeyError: - file = open(absolsute_filename, 'r') + file = open(absolute_filename, 'r') statements = ast.StatementGroup() lineno = 0 - while 1: + while True: lineno = lineno + 1 s = file.readline() if not s: break @@ -101,7 +103,7 @@ def get_statements(filename, absolsute_filename, base_name): feeder(IN_PYTHON_EOF, "", filename, base_name, statements) if filename.endswith(".bbclass") or filename.endswith(".inc"): - cached_statements[absolsute_filename] = statements + cached_statements[absolute_filename] = statements return statements def handle(fn, d, include): @@ -118,7 +120,7 @@ def handle(fn, d, include): bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)") (root, ext) = os.path.splitext(os.path.basename(fn)) - base_name = "%s%s" % (root,ext) + base_name = "%s%s" % (root, ext) init(d) if ext == ".bbclass": @@ -164,7 +166,7 @@ def handle(fn, d, include): return d def feeder(lineno, s, fn, root, statements): - global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__ + global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, classes, bb, __residue__ if __infunc__: if s == '}': __body__.append('') @@ -231,10 +233,9 @@ def feeder(lineno, s, fn, root, statements): ast.handleInherit(statements, m) return - from bb.parse import ConfHandler return ConfHandler.feeder(lineno, s, fn, statements) # Add us to the handlers list -from bb.parse import handlers +from .. import handlers handlers.append({'supports': supports, 'handle': handle, 'init': init}) del handlers diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index f4f85de24..9128a2ef8 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -10,7 +10,7 @@ # Copyright (C) 2003, 2004 Chris Larson # Copyright (C) 2003, 2004 Phil Blundell -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. @@ -24,7 +24,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import re, bb.data, os, sys +import re, bb.data, os +import bb.utils from bb.parse import ParseError, resolve_file, ast #__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") @@ -36,10 +37,7 @@ __export_regexp__ = re.compile( r"export\s+(.+)" ) def init(data): topdir = bb.data.getVar('TOPDIR', data) if not topdir: - topdir = os.getcwd() - bb.data.setVar('TOPDIR', topdir, data) - if not bb.data.getVar('BBPATH', data): - bb.fatal("The BBPATH environment variable must be set") + bb.data.setVar('TOPDIR', os.getcwd(), data) def supports(fn, d): @@ -60,7 +58,7 @@ def include(oldfn, fn, data, error_out): if not os.path.isabs(fn): dname = os.path.dirname(oldfn) bbpath = "%s:%s" % (dname, bb.data.getVar("BBPATH", data, 1)) - abs_fn = bb.which(bbpath, fn) + abs_fn = bb.utils.which(bbpath, fn) if abs_fn: fn = abs_fn @@ -88,7 +86,7 @@ def handle(fn, data, include): statements = ast.StatementGroup() lineno = 0 - while 1: + while True: lineno = lineno + 1 s = f.readline() if not s: break diff --git a/bitbake/lib/bb/parse/parse_py/__init__.py b/bitbake/lib/bb/parse/parse_py/__init__.py index 9e0e00add..3e658d0de 100644 --- a/bitbake/lib/bb/parse/parse_py/__init__.py +++ b/bitbake/lib/bb/parse/parse_py/__init__.py @@ -25,9 +25,9 @@ File parsers for the BitBake build tools. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Based on functions from the base bb module, Copyright 2003 Holger Schurig -__version__ = '1.0' -__all__ = [ 'ConfHandler', 'BBHandler'] +from __future__ import absolute_import +from . import ConfHandler +from . import BBHandler -import ConfHandler -import BBHandler +__version__ = '1.0' |