Created
May 25, 2012 14:25
-
-
Save kergoth/2788410 to your computer and use it in GitHub Desktop.
Playing around with json in bitbake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/lib/bb/parse/ast.py w/lib/bb/parse/ast.py | |
index eae840f..2fa5664 100644 | |
--- i/lib/bb/parse/ast.py | |
+++ w/lib/bb/parse/ast.py | |
@@ -102,13 +102,23 @@ class DataNode(AstNode): | |
bb.data.update_data(e) | |
val = e.expand(groupd["value"], key + "[:=]") | |
elif "append" in groupd and groupd["append"] != None: | |
- val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"]) | |
+ val = self.getFunc(key, data) or "" | |
+ if isinstance(val, basestring): | |
+ val += " " + groupd["value"] | |
+ else: | |
+ val += groupd["value"] | |
elif "prepend" in groupd and groupd["prepend"] != None: | |
- val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or "")) | |
+ val = self.getFunc(key, data) or "" | |
+ if isinstance(val, basestring): | |
+ val = groupd["value"] + " " + val | |
+ else: | |
+ val = groupd["value"] + val | |
elif "postdot" in groupd and groupd["postdot"] != None: | |
- val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"]) | |
+ val = self.getFunc(key, data) or "" | |
+ val += groupd["value"] | |
elif "predot" in groupd and groupd["predot"] != None: | |
- val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or "")) | |
+ val = self.getFunc(key, data) or "" | |
+ val = groupd["value"] + val | |
else: | |
val = groupd["value"] | |
diff --git i/lib/bb/parse/parse_py/ConfHandler.py w/lib/bb/parse/parse_py/ConfHandler.py | |
index 1edf2ef..85aa90d 100644 | |
--- i/lib/bb/parse/parse_py/ConfHandler.py | |
+++ w/lib/bb/parse/parse_py/ConfHandler.py | |
@@ -25,12 +25,12 @@ | |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
import re, os | |
+import json | |
import logging | |
import bb.utils | |
from bb.parse import ParseError, resolve_file, ast, logger | |
-#__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)$") | |
-__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<lazyques>\?\?=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") | |
+__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<lazyques>\?\?=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<value>(?P<apo>['\"]?).*(?P=apo))$") | |
__include_regexp__ = re.compile( r"include\s+(.+)" ) | |
__require_regexp__ = re.compile( r"require\s+(.+)" ) | |
__export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" ) | |
@@ -125,6 +125,11 @@ def feeder(lineno, s, fn, statements): | |
m = __config_regexp__.match(s) | |
if m: | |
groupd = m.groupdict() | |
+ if groupd["apo"]: | |
+ value = groupd["value"][1:-1] | |
+ else: | |
+ value = json.loads(groupd["value"]) | |
+ groupd["value"] = value | |
ast.handleData(statements, fn, lineno, groupd) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FOO = true | |
BAR = [5,7,9] | |
BAR += [11,13] | |
BAZ = {"foo": "bar"} | |
ALPHA = 5 | |
ALPHA_append = 3 | |
BETA = ["foo", "bar"] | |
BETA =+ ["alpha", "beta"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment