diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-03-24 16:56:12 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-07-02 15:41:32 +0100 |
commit | 7acc132cac873e60005516272473a55a8160b9c4 (patch) | |
tree | 2e4122862ffd856803160b6089fcb979d3efd630 /bitbake/lib/bb/data_smart.py | |
parent | bbf83fd988ca3cf9dae7d2b542a11a7c942b1702 (diff) | |
download | poky-7acc132cac873e60005516272473a55a8160b9c4.tar.gz |
Formatting cleanups
(Bitbake rev: 2caf134b43a44dad30af4fbe33033b3c58deee57)
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 | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 6ea0182852..5ff0b37bfc 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -31,11 +31,11 @@ BitBake build tools. | |||
31 | import copy, os, re, sys, time, types | 31 | import copy, os, re, sys, time, types |
32 | import bb | 32 | import bb |
33 | from bb import utils, methodpool | 33 | from bb import utils, methodpool |
34 | from COW import COWDictBase | 34 | from bb.COW import COWDictBase |
35 | from new import classobj | 35 | from new import classobj |
36 | 36 | ||
37 | 37 | ||
38 | __setvar_keyword__ = ["_append","_prepend"] | 38 | __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"\${@.+?}") |
@@ -51,7 +51,7 @@ class DataSmart: | |||
51 | 51 | ||
52 | self.expand_cache = {} | 52 | self.expand_cache = {} |
53 | 53 | ||
54 | def expand(self,s, varname): | 54 | def expand(self, s, varname): |
55 | def var_sub(match): | 55 | def var_sub(match): |
56 | key = match.group()[2:-1] | 56 | key = match.group()[2:-1] |
57 | if varname and key: | 57 | if varname and key: |
@@ -165,7 +165,7 @@ class DataSmart: | |||
165 | if not var in self.dict: | 165 | if not var in self.dict: |
166 | self.dict[var] = {} | 166 | self.dict[var] = {} |
167 | 167 | ||
168 | def _findVar(self,var): | 168 | def _findVar(self, var): |
169 | _dest = self.dict | 169 | _dest = self.dict |
170 | 170 | ||
171 | while (_dest and var not in _dest): | 171 | while (_dest and var not in _dest): |
@@ -189,7 +189,7 @@ class DataSmart: | |||
189 | else: | 189 | else: |
190 | self.initVar(var) | 190 | self.initVar(var) |
191 | 191 | ||
192 | def setVar(self,var,value): | 192 | def setVar(self, var, value): |
193 | self.expand_cache = {} | 193 | self.expand_cache = {} |
194 | match = __setvar_regexp__.match(var) | 194 | match = __setvar_regexp__.match(var) |
195 | if match and match.group("keyword") in __setvar_keyword__: | 195 | if match and match.group("keyword") in __setvar_keyword__: |
@@ -223,16 +223,16 @@ class DataSmart: | |||
223 | # setting var | 223 | # setting var |
224 | self.dict[var]["content"] = value | 224 | self.dict[var]["content"] = value |
225 | 225 | ||
226 | def getVar(self,var,exp): | 226 | def getVar(self, var, exp): |
227 | value = self.getVarFlag(var,"content") | 227 | value = self.getVarFlag(var, "content") |
228 | 228 | ||
229 | if exp and value: | 229 | if exp and value: |
230 | return self.expand(value,var) | 230 | return self.expand(value, var) |
231 | return value | 231 | return value |
232 | 232 | ||
233 | def renameVar(self, key, newkey): | 233 | def renameVar(self, key, newkey): |
234 | """ | 234 | """ |
235 | Rename the variable key to newkey | 235 | Rename the variable key to newkey |
236 | """ | 236 | """ |
237 | val = self.getVar(key, 0) | 237 | val = self.getVar(key, 0) |
238 | if val is not None: | 238 | if val is not None: |
@@ -246,30 +246,30 @@ class DataSmart: | |||
246 | dest = self.getVarFlag(newkey, i) or [] | 246 | dest = self.getVarFlag(newkey, i) or [] |
247 | dest.extend(src) | 247 | dest.extend(src) |
248 | self.setVarFlag(newkey, i, dest) | 248 | self.setVarFlag(newkey, i, dest) |
249 | 249 | ||
250 | if self._special_values.has_key(i) and key in self._special_values[i]: | 250 | if self._special_values.has_key(i) and key in self._special_values[i]: |
251 | self._special_values[i].remove(key) | 251 | self._special_values[i].remove(key) |
252 | self._special_values[i].add(newkey) | 252 | self._special_values[i].add(newkey) |
253 | 253 | ||
254 | self.delVar(key) | 254 | self.delVar(key) |
255 | 255 | ||
256 | def delVar(self,var): | 256 | def delVar(self, var): |
257 | self.expand_cache = {} | 257 | self.expand_cache = {} |
258 | self.dict[var] = {} | 258 | self.dict[var] = {} |
259 | 259 | ||
260 | def setVarFlag(self,var,flag,flagvalue): | 260 | def setVarFlag(self, var, flag, flagvalue): |
261 | if not var in self.dict: | 261 | if not var in self.dict: |
262 | self._makeShadowCopy(var) | 262 | self._makeShadowCopy(var) |
263 | self.dict[var][flag] = flagvalue | 263 | self.dict[var][flag] = flagvalue |
264 | 264 | ||
265 | def getVarFlag(self,var,flag): | 265 | def getVarFlag(self, var, flag): |
266 | local_var = self._findVar(var) | 266 | local_var = self._findVar(var) |
267 | if local_var: | 267 | if local_var: |
268 | if flag in local_var: | 268 | if flag in local_var: |
269 | return copy.copy(local_var[flag]) | 269 | return copy.copy(local_var[flag]) |
270 | return None | 270 | return None |
271 | 271 | ||
272 | def delVarFlag(self,var,flag): | 272 | def delVarFlag(self, var, flag): |
273 | local_var = self._findVar(var) | 273 | local_var = self._findVar(var) |
274 | if not local_var: | 274 | if not local_var: |
275 | return | 275 | return |
@@ -279,7 +279,7 @@ class DataSmart: | |||
279 | if var in self.dict and flag in self.dict[var]: | 279 | if var in self.dict and flag in self.dict[var]: |
280 | del self.dict[var][flag] | 280 | del self.dict[var][flag] |
281 | 281 | ||
282 | def setVarFlags(self,var,flags): | 282 | def setVarFlags(self, var, flags): |
283 | if not var in self.dict: | 283 | if not var in self.dict: |
284 | self._makeShadowCopy(var) | 284 | self._makeShadowCopy(var) |
285 | 285 | ||
@@ -288,7 +288,7 @@ class DataSmart: | |||
288 | continue | 288 | continue |
289 | self.dict[var][i] = flags[i] | 289 | self.dict[var][i] = flags[i] |
290 | 290 | ||
291 | def getVarFlags(self,var): | 291 | def getVarFlags(self, var): |
292 | local_var = self._findVar(var) | 292 | local_var = self._findVar(var) |
293 | flags = {} | 293 | flags = {} |
294 | 294 | ||
@@ -303,7 +303,7 @@ class DataSmart: | |||
303 | return flags | 303 | return flags |
304 | 304 | ||
305 | 305 | ||
306 | def delVarFlags(self,var): | 306 | def delVarFlags(self, var): |
307 | if not var in self.dict: | 307 | if not var in self.dict: |
308 | self._makeShadowCopy(var) | 308 | self._makeShadowCopy(var) |
309 | 309 | ||
@@ -333,21 +333,19 @@ class DataSmart: | |||
333 | def keys(self): | 333 | def keys(self): |
334 | def _keys(d, mykey): | 334 | def _keys(d, mykey): |
335 | if "_data" in d: | 335 | if "_data" in d: |
336 | _keys(d["_data"],mykey) | 336 | _keys(d["_data"], mykey) |
337 | 337 | ||
338 | for key in d.keys(): | 338 | for key in d.keys(): |
339 | if key != "_data": | 339 | if key != "_data": |
340 | mykey[key] = None | 340 | mykey[key] = None |
341 | keytab = {} | 341 | keytab = {} |
342 | _keys(self.dict,keytab) | 342 | _keys(self.dict, keytab) |
343 | return keytab.keys() | 343 | return keytab.keys() |
344 | 344 | ||
345 | def __getitem__(self,item): | 345 | def __getitem__(self, item): |
346 | #print "Warning deprecated" | 346 | #print "Warning deprecated" |
347 | return self.getVar(item, False) | 347 | return self.getVar(item, False) |
348 | 348 | ||
349 | def __setitem__(self,var,data): | 349 | def __setitem__(self, var, data): |
350 | #print "Warning deprecated" | 350 | #print "Warning deprecated" |
351 | self.setVar(var,data) | 351 | self.setVar(var, data) |
352 | |||
353 | |||