aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/cooker.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bb/cooker.py')
-rw-r--r--lib/bb/cooker.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index c8d898ef..70a44c62 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -32,6 +32,7 @@ import sre_constants
import threading
from cStringIO import StringIO
from contextlib import closing
+from functools import wraps
import bb
from bb import utils, data, parse, event, cache, providers, taskdata, command, runqueue
@@ -495,12 +496,6 @@ class BBCooker:
path, _ = os.path.split(path)
def parseConfigurationFiles(self, files):
- def _parse(f, data, include=False):
- try:
- return bb.parse.handle(f, data, include)
- except (IOError, bb.parse.ParseError) as exc:
- parselog.critical("Unable to parse %s: %s" % (f, exc))
- sys.exit(1)
data = self.configuration.data
bb.parse.init_parser(data)
@@ -941,6 +936,21 @@ def parse_file(task):
exc.recipe = filename
raise exc
+def catch_parse_error(func):
+ """Exception handling bits for our parsing"""
+ @wraps(func)
+ def wrapped(fn, *args):
+ try:
+ return func(fn, *args)
+ except (IOError, bb.parse.ParseError) as exc:
+ parselog.critical("Unable to parse %s: %s" % (fn, exc))
+ sys.exit(1)
+ return wrapped
+
+@catch_parse_error
+def _parse(fn, data, include=False):
+ return bb.parse.handle(fn, data, include)
+
class CookerParser(object):
def __init__(self, cooker, filelist, masked):
self.filelist = filelist