diff options
Diffstat (limited to 'bitbake/lib/bb/parse/__init__.py')
| -rw-r--r-- | bitbake/lib/bb/parse/__init__.py | 15 |
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 | ||
| 38 | class ParseError(Exception): | 38 | class 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 | ||
| 41 | class SkipPackage(Exception): | 52 | class 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 | ||
| 83 | def init(fn, data): | 94 | def 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: |
