diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-11-08 18:02:15 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-11-10 11:51:11 +0000 |
commit | 2203a31dcbc89cc8226c483f5d18cf451725792c (patch) | |
tree | 91b571ac9f65a003b00e14b95cdeea11dd310156 /bitbake/lib | |
parent | 12c6bcbf49d8be27545c132e6f8a18ab4b8fbccd (diff) | |
download | poky-2203a31dcbc89cc8226c483f5d18cf451725792c.tar.gz |
data_smart: Add appendVar/prependVar functions
This patch adds appendVar and prependVar functions to the data store
meaning python code would no longer have to do the getVar, append and
the setVar dance that much of the current python code does.
It also adds corresponding variants for flags.
Currently there is no spacing added by these functions. That could be
added as a parameter if desired.
If these functions turn out to be hotspots in the code, there are tricks
that could potentially be used to increase the speed of these specific
operations within the datastore.
(Bitbake rev: 4a4046268f84b85559eea2c4b6a6004ad8cccb77)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 072f4033a0..ec4e9210b2 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -304,6 +304,14 @@ class DataSmart(MutableMapping): | |||
304 | 304 | ||
305 | self.delVar(key) | 305 | self.delVar(key) |
306 | 306 | ||
307 | def appendVar(self, key, value): | ||
308 | value = (self.getVar(key, False) or "") + value | ||
309 | self.setVar(key, value) | ||
310 | |||
311 | def prependVar(self, key, value): | ||
312 | value = value + (self.getVar(key, False) or "") | ||
313 | self.setVar(key, value) | ||
314 | |||
307 | def delVar(self, var): | 315 | def delVar(self, var): |
308 | self.expand_cache = {} | 316 | self.expand_cache = {} |
309 | self.dict[var] = {} | 317 | self.dict[var] = {} |
@@ -339,6 +347,14 @@ class DataSmart(MutableMapping): | |||
339 | if var in self.dict and flag in self.dict[var]: | 347 | if var in self.dict and flag in self.dict[var]: |
340 | del self.dict[var][flag] | 348 | del self.dict[var][flag] |
341 | 349 | ||
350 | def appendVarFlag(self, key, flag, value): | ||
351 | value = (self.getVarFlag(key, flag, False) or "") + value | ||
352 | self.setVarFlag(key, flag, value) | ||
353 | |||
354 | def prependVarFlag(self, key, flag, value): | ||
355 | value = value + (self.getVarFlag(key, flag, False) or "") | ||
356 | self.setVarFlag(key, flag, value) | ||
357 | |||
342 | def setVarFlags(self, var, flags): | 358 | def setVarFlags(self, var, flags): |
343 | if not var in self.dict: | 359 | if not var in self.dict: |
344 | self._makeShadowCopy(var) | 360 | self._makeShadowCopy(var) |