1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-20 20:09:11 +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:
Marc Bonnici 2018-01-16 16:39:17 +00:00 committed by setrofim
parent 2699bceba3
commit d9a7e1c475

View File

@ -389,6 +389,16 @@ class toggle_set(set):
other = copy(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):
"""
returns a list of enabled items.