fix(TextHandler): correcting case_sensitive argument logic
This is awkward, I can't believe how this slipped from me!
This commit is contained in:
+8
-8
@@ -763,25 +763,25 @@ class Adaptor(SelectorsGeneration):
|
||||
return self.get_all_text(strip=True).json()
|
||||
|
||||
def re(self, regex: Union[str, Pattern[str]], replace_entities: bool = True,
|
||||
clean_match: bool = False, case_sensitive: bool = False) -> TextHandlers:
|
||||
clean_match: bool = False, case_sensitive: bool = True) -> TextHandlers:
|
||||
"""Apply the given regex to the current text and return a list of strings with the matches.
|
||||
|
||||
:param regex: Can be either a compiled regular expression or a string.
|
||||
:param replace_entities: if enabled character entity references are replaced by their corresponding character
|
||||
:param clean_match: if enabled, this will ignore all whitespaces and consecutive spaces while matching
|
||||
:param case_sensitive: if enabled, function will set the regex to ignore letters case while compiling it
|
||||
:param case_sensitive: if disabled, function will set the regex to ignore letters case while compiling it
|
||||
"""
|
||||
return self.text.re(regex, replace_entities, clean_match, case_sensitive)
|
||||
|
||||
def re_first(self, regex: Union[str, Pattern[str]], default=None, replace_entities: bool = True,
|
||||
clean_match: bool = False, case_sensitive: bool = False) -> TextHandler:
|
||||
clean_match: bool = False, case_sensitive: bool = True) -> TextHandler:
|
||||
"""Apply the given regex to text and return the first match if found, otherwise return the default value.
|
||||
|
||||
:param regex: Can be either a compiled regular expression or a string.
|
||||
:param default: The default value to be returned if there is no match
|
||||
:param replace_entities: if enabled character entity references are replaced by their corresponding character
|
||||
:param clean_match: if enabled, this will ignore all whitespaces and consecutive spaces while matching
|
||||
:param case_sensitive: if enabled, function will set the regex to ignore letters case while compiling it
|
||||
:param case_sensitive: if disabled, function will set the regex to ignore letters case while compiling it
|
||||
"""
|
||||
return self.text.re_first(regex, default, replace_entities, clean_match, case_sensitive)
|
||||
|
||||
@@ -1009,14 +1009,14 @@ class Adaptors(List[Adaptor]):
|
||||
return self.__class__(flatten(results))
|
||||
|
||||
def re(self, regex: Union[str, Pattern[str]], replace_entities: bool = True,
|
||||
clean_match: bool = False, case_sensitive: bool = False) -> TextHandlers[TextHandler]:
|
||||
clean_match: bool = False, case_sensitive: bool = True) -> TextHandlers[TextHandler]:
|
||||
"""Call the ``.re()`` method for each element in this list and return
|
||||
their results flattened as List of TextHandler.
|
||||
|
||||
:param regex: Can be either a compiled regular expression or a string.
|
||||
:param replace_entities: if enabled character entity references are replaced by their corresponding character
|
||||
:param clean_match: if enabled, this will ignore all whitespaces and consecutive spaces while matching
|
||||
:param case_sensitive: if enabled, function will set the regex to ignore letters case while compiling it
|
||||
:param case_sensitive: if disabled, function will set the regex to ignore letters case while compiling it
|
||||
"""
|
||||
results = [
|
||||
n.text.re(regex, replace_entities, clean_match, case_sensitive) for n in self
|
||||
@@ -1024,7 +1024,7 @@ class Adaptors(List[Adaptor]):
|
||||
return TextHandlers(flatten(results))
|
||||
|
||||
def re_first(self, regex: Union[str, Pattern[str]], default=None, replace_entities: bool = True,
|
||||
clean_match: bool = False, case_sensitive: bool = False) -> TextHandler:
|
||||
clean_match: bool = False, case_sensitive: bool = True) -> TextHandler:
|
||||
"""Call the ``.re_first()`` method for each element in this list and return
|
||||
the first result or the default value otherwise.
|
||||
|
||||
@@ -1032,7 +1032,7 @@ class Adaptors(List[Adaptor]):
|
||||
:param default: The default value to be returned if there is no match
|
||||
:param replace_entities: if enabled character entity references are replaced by their corresponding character
|
||||
:param clean_match: if enabled, this will ignore all whitespaces and consecutive spaces while matching
|
||||
:param case_sensitive: if enabled, function will set the regex to ignore letters case while compiling it
|
||||
:param case_sensitive: if disabled, function will set the regex to ignore letters case while compiling it
|
||||
"""
|
||||
for n in self:
|
||||
for result in n.re(regex, replace_entities, clean_match, case_sensitive):
|
||||
|
||||
Reference in New Issue
Block a user