rmeove dead code

This commit is contained in:
2021-09-11 00:32:10 +02:00
parent 33f0702c26
commit 29bfb064e9
2 changed files with 0 additions and 55 deletions

View File

@ -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