mirror of
https://github.com/progval/irctest.git
synced 2025-04-08 00:09:46 +00:00
rmeove dead code
This commit is contained in:
@ -44,21 +44,3 @@ class MultipleReplacer:
|
||||
|
||||
def __call__(self, s: str) -> str:
|
||||
return self._matcher.sub(lambda m: self._dict[m.group(0)], s)
|
||||
|
||||
|
||||
def normalizeWhitespace(s: str, removeNewline: bool = True) -> str:
|
||||
r"""Normalizes the whitespace in a string; \s+ becomes one space."""
|
||||
if not s:
|
||||
return str(s) # not the same reference
|
||||
starts_with_space = s[0] in " \n\t\r"
|
||||
ends_with_space = s[-1] in " \n\t\r"
|
||||
if removeNewline:
|
||||
newline_re = re.compile("[\r\n]+")
|
||||
s = " ".join(filter(bool, newline_re.split(s)))
|
||||
s = " ".join(filter(bool, s.split("\t")))
|
||||
s = " ".join(filter(bool, s.split(" ")))
|
||||
if starts_with_space:
|
||||
s = " " + s
|
||||
if ends_with_space:
|
||||
s += " "
|
||||
return s
|
||||
|
Reference in New Issue
Block a user