summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-05-22 16:36:08 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:34 +0100
commit50006b49fce055a2e361f70620c6128f477adca9 (patch)
tree7e878ce2d28ed97ff61f160bc2b917fe662ad380
parentd217bedd3224c4896248cb06cbbc40ffc9398cfe (diff)
downloadpoky-50006b49fce055a2e361f70620c6128f477adca9.tar.gz
Revert "In expand, drop the unnecessary second regular expression match"
This reverts commit 05462fa7908fc22988b3dc9d376798d0a46ccb5a. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/data_smart.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 1f2908927b..01a3330245 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -37,6 +37,7 @@ from bb.COW import COWDictBase
37__setvar_keyword__ = ["_append", "_prepend"] 37__setvar_keyword__ = ["_append", "_prepend"]
38__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?') 38__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?')
39__expand_var_regexp__ = re.compile(r"\${[^{}]+}") 39__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
40__expand_python_regexp__ = re.compile(r"\${@.+?}")
40 41
41 42
42class DataSmart: 43class DataSmart:
@@ -50,25 +51,23 @@ class DataSmart:
50 self.expand_cache = {} 51 self.expand_cache = {}
51 52
52 def expand(self, s, varname): 53 def expand(self, s, varname):
53 def python_sub(code):
54 codeobj = compile(code.strip(), varname or "<expansion>", "eval")
55 value = utils.better_eval(codeobj, {"d": self})
56 return str(value)
57
58 def var_sub(match): 54 def var_sub(match):
59 key = match.group()[2:-1] 55 key = match.group()[2:-1]
60 if key[0] == "@": 56 if varname and key:
61 return python_sub(key[1:]) 57 if varname == key:
62 58 raise Exception("variable %s references itself!" % varname)
63 if varname == key:
64 raise Exception("variable %s references itself!" % varname)
65
66 var = self.getVar(key, 1) 59 var = self.getVar(key, 1)
67 if var is not None: 60 if var is not None:
68 return var 61 return var
69 else: 62 else:
70 return match.group() 63 return match.group()
71 64
65 def python_sub(match):
66 code = match.group()[3:-1]
67 codeobj = compile(code.strip(), varname or "<expansion>", "eval")
68 value = utils.better_eval(codeobj, {"d": self})
69 return str(value)
70
72 if not isinstance(s, basestring): # sanity check 71 if not isinstance(s, basestring): # sanity check
73 return s 72 return s
74 73
@@ -79,6 +78,7 @@ class DataSmart:
79 olds = s 78 olds = s
80 try: 79 try:
81 s = __expand_var_regexp__.sub(var_sub, s) 80 s = __expand_var_regexp__.sub(var_sub, s)
81 s = __expand_python_regexp__.sub(python_sub, s)
82 if s == olds: 82 if s == olds:
83 break 83 break
84 except KeyboardInterrupt: 84 except KeyboardInterrupt: