summaryrefslogtreecommitdiffstats
path: root/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-08 18:02:15 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-10 11:39:46 +0000
commit4a4046268f84b85559eea2c4b6a6004ad8cccb77 (patch)
tree8d9e4b89579f5d90469041e01a201bcc919dc8be /lib/bb/data_smart.py
parent05c29ab0b2ad3c521414cabb6a92bca15c6e919c (diff)
downloadbitbake-contrib-4a4046268f84b85559eea2c4b6a6004ad8cccb77.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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r--lib/bb/data_smart.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 072f4033a..ec4e9210b 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -304,6 +304,14 @@ class DataSmart(MutableMapping):
self.delVar(key)
+ def appendVar(self, key, value):
+ value = (self.getVar(key, False) or "") + value
+ self.setVar(key, value)
+
+ def prependVar(self, key, value):
+ value = value + (self.getVar(key, False) or "")
+ self.setVar(key, value)
+
def delVar(self, var):
self.expand_cache = {}
self.dict[var] = {}
@@ -339,6 +347,14 @@ class DataSmart(MutableMapping):
if var in self.dict and flag in self.dict[var]:
del self.dict[var][flag]
+ def appendVarFlag(self, key, flag, value):
+ value = (self.getVarFlag(key, flag, False) or "") + value
+ self.setVarFlag(key, flag, value)
+
+ def prependVarFlag(self, key, flag, value):
+ value = value + (self.getVarFlag(key, flag, False) or "")
+ self.setVarFlag(key, flag, value)
+
def setVarFlags(self, var, flags):
if not var in self.dict:
self._makeShadowCopy(var)