diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-05-21 13:08:44 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-07-02 15:41:34 +0100 |
commit | d00b54b948ecc9a23e39a10a15d9b8c1e564240f (patch) | |
tree | 2a2b84f019d47df99ad5cb5146acdc7da26f860c /bitbake/lib/bb/data_smart.py | |
parent | e07a5b1909d26d6a28910002daf1c0ea21e05ea3 (diff) | |
download | poky-d00b54b948ecc9a23e39a10a15d9b8c1e564240f.tar.gz |
In expand, drop the unnecessary second regular expression match
(Bitbake rev: 05462fa7908fc22988b3dc9d376798d0a46ccb5a)
Signed-off-by: Imran Mehmood <imran_mehmood@mentor.com>
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/data_smart.py')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 01a3330245..1f2908927b 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -37,7 +37,6 @@ 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"\${@.+?}") | ||
41 | 40 | ||
42 | 41 | ||
43 | class DataSmart: | 42 | class DataSmart: |
@@ -51,23 +50,25 @@ class DataSmart: | |||
51 | self.expand_cache = {} | 50 | self.expand_cache = {} |
52 | 51 | ||
53 | def expand(self, s, varname): | 52 | 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 | |||
54 | def var_sub(match): | 58 | def var_sub(match): |
55 | key = match.group()[2:-1] | 59 | key = match.group()[2:-1] |
56 | if varname and key: | 60 | if key[0] == "@": |
57 | if varname == key: | 61 | return python_sub(key[1:]) |
58 | raise Exception("variable %s references itself!" % varname) | 62 | |
63 | if varname == key: | ||
64 | raise Exception("variable %s references itself!" % varname) | ||
65 | |||
59 | var = self.getVar(key, 1) | 66 | var = self.getVar(key, 1) |
60 | if var is not None: | 67 | if var is not None: |
61 | return var | 68 | return var |
62 | else: | 69 | else: |
63 | return match.group() | 70 | return match.group() |
64 | 71 | ||
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 | |||
71 | if not isinstance(s, basestring): # sanity check | 72 | if not isinstance(s, basestring): # sanity check |
72 | return s | 73 | return s |
73 | 74 | ||
@@ -78,7 +79,6 @@ class DataSmart: | |||
78 | olds = s | 79 | olds = s |
79 | try: | 80 | try: |
80 | s = __expand_var_regexp__.sub(var_sub, s) | 81 | 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: |