diff --git a/pymispwarninglists/api.py b/pymispwarninglists/api.py index 1f02d2b..172edf6 100644 --- a/pymispwarninglists/api.py +++ b/pymispwarninglists/api.py @@ -51,6 +51,11 @@ class WarningList(): to_return['matching_attributes'] = self.matching_attributes return to_return + def has_match(self, value): + if value in self.list: + return True + return False + class WarningLists(collections.Mapping): @@ -79,5 +84,12 @@ class WarningLists(collections.Mapping): def __iter__(self): return iter(self.warninglists) + def search(self, value): + matches = [] + for name, wl in self.warninglists.items(): + if wl.has_match(value): + matches.append(wl) + return matches + def __len__(self): return len(self.warninglists)