summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/__init__.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-02-23 17:38:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-23 22:52:15 +0000
commit99d326a818a49faf457c707ceeec6163bf8c8e16 (patch)
tree6e03dca72ed109a691356bd2d9feb172423da6ab /bitbake/lib/bb/parse/__init__.py
parentebc0d4252a19e6ab38052473e54138d29b172dfc (diff)
downloadpoky-99d326a818a49faf457c707ceeec6163bf8c8e16.tar.gz
bitbake: add file and line number to ParseError
Ensure that a file and line number are reported for ParseError where possible. This helps particularly in the case of inherit and require which previously did not report either of these upon failure. (Bitbake rev: f588ba69622a2df35417ced184e56c79ac1b40d5) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse/__init__.py')
-rw-r--r--bitbake/lib/bb/parse/__init__.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py
index c5005aec9a..8b7ec73c57 100644
--- a/bitbake/lib/bb/parse/__init__.py
+++ b/bitbake/lib/bb/parse/__init__.py
@@ -37,6 +37,17 @@ logger = logging.getLogger("BitBake.Parsing")
37 37
38class ParseError(Exception): 38class ParseError(Exception):
39 """Exception raised when parsing fails""" 39 """Exception raised when parsing fails"""
40 def __init__(self, msg, filename, lineno=0):
41 self.msg = msg
42 self.filename = filename
43 self.lineno = lineno
44 Exception.__init__(self, msg, filename, lineno)
45
46 def __str__(self):
47 if self.lineno:
48 return "ParseError at %s:%d: %s" % (self.filename, self.lineno, self.msg)
49 else:
50 return "ParseError in %s: %s" % (self.filename, self.msg)
40 51
41class SkipPackage(Exception): 52class SkipPackage(Exception):
42 """Exception raised to skip this package""" 53 """Exception raised to skip this package"""
@@ -78,7 +89,7 @@ def handle(fn, data, include = 0):
78 for h in handlers: 89 for h in handlers:
79 if h['supports'](fn, data): 90 if h['supports'](fn, data):
80 return h['handle'](fn, data, include) 91 return h['handle'](fn, data, include)
81 raise ParseError("%s is not a BitBake file" % fn) 92 raise ParseError("not a BitBake file", fn)
82 93
83def init(fn, data): 94def init(fn, data):
84 for h in handlers: 95 for h in handlers:
@@ -111,7 +122,7 @@ def vars_from_file(mypkg, d):
111 parts = myfile[0].split('_') 122 parts = myfile[0].split('_')
112 __pkgsplit_cache__[mypkg] = parts 123 __pkgsplit_cache__[mypkg] = parts
113 if len(parts) > 3: 124 if len(parts) > 3:
114 raise ParseError("Unable to generate default variables from the filename: %s (too many underscores)" % mypkg) 125 raise ParseError("Unable to generate default variables from filename (too many underscores)", mypkg)
115 exp = 3 - len(parts) 126 exp = 3 - len(parts)
116 tmplist = [] 127 tmplist = []
117 while exp != 0: 128 while exp != 0: