summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-03-24 18:58:59 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-03-25 17:25:58 +0000
commit964085f701a58c9a612e1230961fe3c22fede7ba (patch)
treeb419e68f05cea6f5bb9273db307e525ed143f208 /bitbake/lib
parent6028daedcb2e3eeab8bb7c725de4303b03625ed8 (diff)
downloadpoky-964085f701a58c9a612e1230961fe3c22fede7ba.tar.gz
data_smart: be explicit about what we make available to eval'd python code
(Bitbake rev: 6a73dda60f50e9b3e5513795d1ec7207d1446de2) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/data_smart.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index dac7fb705e..9067d54bfa 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -39,6 +39,11 @@ __setvar_keyword__ = ["_append","_prepend"]
39__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?') 39__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?')
40__expand_var_regexp__ = re.compile(r"\${[^{}]+}") 40__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
41__expand_python_regexp__ = re.compile(r"\${@.+?}") 41__expand_python_regexp__ = re.compile(r"\${@.+?}")
42_expand_globals = {
43 "os": os,
44 "bb": bb,
45 "time": time,
46}
42 47
43 48
44class DataSmart: 49class DataSmart:
@@ -50,6 +55,7 @@ class DataSmart:
50 self._seen_overrides = seen 55 self._seen_overrides = seen
51 56
52 self.expand_cache = {} 57 self.expand_cache = {}
58 self.expand_locals = {"d": self}
53 59
54 def expand(self,s, varname): 60 def expand(self,s, varname):
55 def var_sub(match): 61 def var_sub(match):
@@ -66,8 +72,7 @@ class DataSmart:
66 def python_sub(match): 72 def python_sub(match):
67 import bb 73 import bb
68 code = match.group()[3:-1] 74 code = match.group()[3:-1]
69 locals()['d'] = self 75 s = eval(code, _expand_globals, self.expand_locals)
70 s = eval(code)
71 if type(s) == types.IntType: s = str(s) 76 if type(s) == types.IntType: s = str(s)
72 return s 77 return s
73 78