mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-02 03:12:34 +01:00
utils/types: fix toggle_set creation
Correctly handle the presence of both an element and its toggle in the input, and handle them base on order, e.g. toggle_set(['x', 'y', '~x']) --> {'y', '~x'} toggle_set(['~x', 'y', 'x']) --> {'y', 'x'}
This commit is contained in:
committed by
Marc Bonnici
parent
0f2de5f951
commit
5f00a94121
@@ -432,6 +432,14 @@ class toggle_set(set):
|
||||
if isinstance(value, str):
|
||||
msg = 'invalid type for toggle_set: "{}"'
|
||||
raise TypeError(msg.format(type(value)))
|
||||
updated_value = []
|
||||
for v in value:
|
||||
if v.startswith('~') and v[1:] in updated_value:
|
||||
updated_value.remove(v[1:])
|
||||
elif not v.startswith('~') and ('~' + v) in updated_value:
|
||||
updated_value.remove(('~' + v))
|
||||
updated_value.append(v)
|
||||
args = tuple([updated_value] + list(args[1:]))
|
||||
set.__init__(self, *args)
|
||||
|
||||
def merge_with(self, other):
|
||||
|
Reference in New Issue
Block a user