Add simple search

regex-type
Raphaël Vinot 2017-10-30 22:11:37 -04:00
parent b4f1b9dd69
commit 3895df0ea8
1 changed files with 12 additions and 0 deletions

View File

@ -51,6 +51,11 @@ class WarningList():
to_return['matching_attributes'] = self.matching_attributes to_return['matching_attributes'] = self.matching_attributes
return to_return return to_return
def has_match(self, value):
if value in self.list:
return True
return False
class WarningLists(collections.Mapping): class WarningLists(collections.Mapping):
@ -79,5 +84,12 @@ class WarningLists(collections.Mapping):
def __iter__(self): def __iter__(self):
return iter(self.warninglists) 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): def __len__(self):
return len(self.warninglists) return len(self.warninglists)