mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-22 04:49:00 +00:00
utils/types: Add add
method to toggle_set
Allows adding of elements that will respect the state of an existing element in the toggle set.
This commit is contained in:
parent
2699bceba3
commit
d9a7e1c475
@ -389,6 +389,16 @@ class toggle_set(set):
|
|||||||
other = copy(other)
|
other = copy(other)
|
||||||
return toggle_set.merge(self, other)
|
return toggle_set.merge(self, other)
|
||||||
|
|
||||||
|
def add(self, item):
|
||||||
|
if item not in self:
|
||||||
|
#Disable previously enabled item
|
||||||
|
if item.startswith('~') and item[1:] in self:
|
||||||
|
self.remove(item[1:])
|
||||||
|
#Enable previously disabled item
|
||||||
|
if not item.startswith('~') and ('~' + item) in self:
|
||||||
|
self.remove('~' + item)
|
||||||
|
super(toggle_set, self).add(item)
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
"""
|
"""
|
||||||
returns a list of enabled items.
|
returns a list of enabled items.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user