Skip to contentSkip to conversation

[1.12][PATCH] tinfoil: backport to 1.12

PATCH Paul Eggleton 1 participant 1 message Jun 18, 2013

lore
Share & tools
lore
#0 lore raw

Backport the tinfoil wrapper that allows external utilities to make use of bitbake code easily. This allows the OpenEmbedded layer index to parse recipes from OE-Classic.

---
 lib/bb/cooker.py  | 22 +++++++++----
 lib/bb/tinfoil.py | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 111 insertions(+), 6 deletions(-)
 create mode 100644 lib/bb/tinfoil.py
lib/bb/cooker.py +16 -6
index c8d898e..70a44c6 100644
@@ -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
lib/bb/tinfoil.py new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.8.1.2