Source code for unbrowsed.matchers
"""unbrowsed matchers."""
[docs]
class TextMatch:
"""Wrapper class for text matching."""
def __init__(self, text: str, exact=True) -> None:
if not isinstance(text, str):
raise TypeError("text must be a string")
self.text = text.strip()
self.exact = exact
[docs]
def matches(self, other: str) -> bool:
if not self.exact:
return self.text.lower() in other.lower()
return self.text == other