lib/bb/data_smart: add removeFromVar method
PATCH 1/1 lib/bb/data_smart: add removeFromVar method
Tested with:
MY_VARIABLE = "foo hello foo world"
python () {
d.removeFromVar('MY_VARIABLE', 'foo')
}
$ bitbake-getvar -r example --value MY_VARIABLE hello world
--- lib/bb/data_smart.py | 5 +++++ 1 file changed, 5 insertions(+)
lib/bb/data_smart.py +5 -0
@@ -714,6 +714,11 @@ class DataSmart(MutableMapping): self.varhistory.record(**loginfo) self.setVar(var + ":prepend", value, ignore=True, parsing=True) + def removeFromVar(self, var, value, **loginfo): + loginfo['op'] = 'remove' + self.varhistory.record(**loginfo) + self.setVar(var + ":remove", value, ignore=True, parsing=True) + def delVar(self, var, **loginfo): self.expand_cache = {}
Signature · 1 line
2.51.0
Quoted 10 lines · BELHADJ SALEM Talel via lists.openembedded.org
Tested with:
MY_VARIABLE= "foo hello foo world"
python () {
d.removeFromVar('MY_VARIABLE', 'foo')
}$ bitbake-getvar -r example --value MY_VARIABLE hello world
Out of curiosity, what does the variable history look like? (same command without the --value)
Quoted 36 lines
Signed-off-by Talel BELHAJ SALEM <[email protected]>--- lib/bb/data_smart.py | 5 +++++ 1 file changed, 5 insertions(+)lib/bb/data_smart.py +5
-1@@ -714,6 +714,11 @@ class DataSmart(MutableMapping): self.varhistory.record(**loginfo) self.setVar(var + ":prepend", value, ignore=True, parsing=True) + def removeFromVar(self, var, value, **loginfo): + loginfo['op'] = 'remove' + self.varhistory.record(**loginfo) + self.setVar(var + ":remove", value, ignore=True, parsing=True) + def delVar(self, var, **loginfo): self.expand_cache = {} --2.51.0
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#18156):
https://lists.openembedded.org/g/bitbake-devel/message/18156
Mute This Topic: https://lists.openembedded.org/mt/115676008/4316185
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 2 lines
Yoann Congal Smile ECS
It has two actions on it : set and remove:
$ bitbake-getvar -r example MY_VARIABLE
Quoted 10 lines
#
# $MY_VARIABLE [2 operations]
# set /work/meta-test/recipes-example/example/example_0.1.bb:5
# "foo hello foo world"
# remove example_0.1.bb:8
[__anon_9__work_meta_test_recipes_example_example_example_0_1_bb]
# "foo"# pre-expansion value: # "foo hello foo world" MY_VARIABLE=" hello world"
Quoted 62 lines · Yoann Congal
Le jeu. 9 oct. 2025 à 19:53, BELHADJ SALEM Talel via lists.openembedded.org <[email protected]> a écrit :
Quoted 10 lines
Tested with:
MY_VARIABLE= "foo hello foo world"
python () {
d.removeFromVar('MY_VARIABLE', 'foo')
}$ bitbake-getvar -r example --value MY_VARIABLE hello worldOut of curiosity, what does the variable history look like? (same command without the --value)
Quoted 25 lines
Signed-off-by Talel BELHAJ SALEM <[email protected]>--- lib/bb/data_smart.py | 5 +++++ 1 file changed, 5 insertions(+)lib/bb/data_smart.py +5
-1@@ -714,6 +714,11 @@ class DataSmart(MutableMapping): self.varhistory.record(**loginfo) self.setVar(var + ":prepend", value, ignore=True, parsing=True) + def removeFromVar(self, var, value, **loginfo): + loginfo['op'] = 'remove' + self.varhistory.record(**loginfo) + self.setVar(var + ":remove", value, ignore=True, parsing=True) + def delVar(self, var, **loginfo): self.expand_cache = {} --2.51.0
Quoted 11 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#18156):
https://lists.openembedded.org/g/bitbake-devel/message/18156
Mute This Topic: https://lists.openembedded.org/mt/115676008/4316185
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
Yoann Congal
Smile ECS
Le jeu. 9 oct. 2025 à 20:03, Talel BELHADJ SALEM <[email protected]> a écrit :
Quoted 15 lines
It has two actions on it : set and remove:
$ bitbake-getvar -r example MY_VARIABLEQuoted 10 lines
#
# $MY_VARIABLE [2 operations]
# set /work/meta-test/recipes-example/example/example_0.1.bb:5
# "foo hello foo world"
# remove example_0.1.bb:8
[__anon_9__work_meta_test_recipes_example_example_example_0_1_bb]
# "foo"# pre-expansion value: # "foo hello foo world" MY_VARIABLE=" hello world"
Thank you. It does look good!
Quoted 65 lines · Yoann Congal
Quoted 63 lines
Le jeu. 9 oct. 2025 à 19:53, BELHADJ SALEM Talel via lists.openembedded.org <[email protected]> a écrit :
Quoted 10 lines
Tested with:
MY_VARIABLE= "foo hello foo world"
python () {
d.removeFromVar('MY_VARIABLE', 'foo')
}$ bitbake-getvar -r example --value MY_VARIABLE hello worldOut of curiosity, what does the variable history look like? (same command without the --value)
Quoted 25 lines
Signed-off-by Talel BELHAJ SALEM <[email protected]>--- lib/bb/data_smart.py | 5 +++++ 1 file changed, 5 insertions(+)lib/bb/data_smart.py +5
-1@@ -714,6 +714,11 @@ class DataSmart(MutableMapping): self.varhistory.record(**loginfo) self.setVar(var + ":prepend", value, ignore=True, parsing=True) + def removeFromVar(self, var, value, **loginfo): + loginfo['op'] = 'remove' + self.varhistory.record(**loginfo) + self.setVar(var + ":remove", value, ignore=True, parsing=True) + def delVar(self, var, **loginfo): self.expand_cache = {} --2.51.0
Quoted 11 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#18156):
https://lists.openembedded.org/g/bitbake-devel/message/18156
Mute This Topic: https://lists.openembedded.org/mt/115676008/4316185
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
Yoann Congal
Smile ECS
Signature · 2 lines
Yoann Congal Smile ECS
Quoted 10 lines · BELHADJ SALEM Talel via lists.openembedded.org
Tested with:
MY_VARIABLE= "foo hello foo world"
python () {
d.removeFromVar('MY_VARIABLE', 'foo')
}$ bitbake-getvar -r example --value MY_VARIABLE hello world
I’m curious what the use case for this: if you’re programmatically manipulating the data store can you not just make the desired changes directly, instead of adding another operator which has to be evaluated and has a performance hit?
Ross
Quoted 11 lines · Ross Burton via lists.openembedded.org
Quoted 8 lines · BELHADJ SALEM Talel via lists.openembedded.org
Tested with:
MY_VARIABLE= "foo hello foo world"
python () {
d.removeFromVar('MY_VARIABLE', 'foo')
}
Quoted 7 lines
Quoted 2 lines
$ bitbake-getvar -r example --value MY_VARIABLE hello worldI’m curious what the use case for this: if you’re programmatically manipulating the data store can you not just make the desired changes directly, instead of adding another operator which has to be evaluated and has a performance hit?
I haven't taken this as I have the same feelings as Ross. Whilst we can add API, the real question is whether it does something which is useful and can't easily be done another way.
In this case, whilst it might have some minor use cases, it can be done other ways. It also doesn't allow for optimisation, which was the reason for adding some other APIs.
As such I'm not sure this patch meets the high bar requirements for new API...
Cheers,
Richard