diff options
author | 2016-04-09 01:08:51 +0300 | |
---|---|---|
committer | 2016-04-09 01:08:51 +0300 | |
commit | 9e63f57a80722751221e18ae1e42a7f7ac4983ab (patch) | |
tree | 7ea53ae052da8e5b4b84b0a8f6951183159da62d /scripts/automation/trex_control_plane | |
parent | 6adf866fc403829d5e24603280c6c6917b9fc357 (diff) |
added multiple toggle option
all test passed!
Diffstat (limited to 'scripts/automation/trex_control_plane')
-rw-r--r-- | scripts/automation/trex_control_plane/common/filters.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/common/filters.py b/scripts/automation/trex_control_plane/common/filters.py index 3a05f4d1..d2ca7b16 100644 --- a/scripts/automation/trex_control_plane/common/filters.py +++ b/scripts/automation/trex_control_plane/common/filters.py @@ -23,6 +23,9 @@ class ToggleFilter(object): else: raise KeyError("Provided item key isn't a key of the referenced data structure.") + def toggle_items(self, *args): + return all(map(self.toggle_item, args)) + def filter_items(self): """ Filters the pointed database by showing only the items mapped at toggle_db set. @@ -41,7 +44,7 @@ class ToggleFilter(object): if isinstance(self._data, dict): self._filter_method = ToggleFilter.dict_filter if show_by_default: - self._toggle_db = self._data.keys() + self._toggle_db = set(self._data.keys()) return elif isinstance(self._data, list): self._filter_method = ToggleFilter.list_filter @@ -65,7 +68,7 @@ class ToggleFilter(object): assert isinstance(iterable, dict) return {k: v for k,v in iterable.iteritems() - if function(k, v)} + if function(k)} @staticmethod def list_filter(function, iterable): |