From 9e63f57a80722751221e18ae1e42a7f7ac4983ab Mon Sep 17 00:00:00 2001 From: Dan Klein Date: Sat, 9 Apr 2016 01:08:51 +0300 Subject: added multiple toggle option all test passed! --- scripts/automation/trex_control_plane/common/filters.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts/automation/trex_control_plane') 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): -- cgit