-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsearch.py
More file actions
19 lines (12 loc) · 573 Bytes
/
search.py
File metadata and controls
19 lines (12 loc) · 573 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""The standard `search` function extension."""
from ._pattern import AbstractRegexFilterFunction
class Search(AbstractRegexFilterFunction):
"""The standard `search` function."""
def __call__(self, value: object, pattern: object) -> bool:
"""Return `True` if _value_ matches _pattern_, or `False` otherwise."""
if not isinstance(value, str) or not isinstance(pattern, str):
return False
_pattern = self.check_cache(pattern)
if _pattern is None:
return False
return bool(_pattern.search(value))