diff options
| author | 2019-10-10 10:32:47 +0100 | |
|---|---|---|
| committer | 2019-10-10 10:33:18 +0100 | |
| commit | 0331b763ffa845f3cb7b9651ca70ab8b407eb67e (patch) | |
| tree | 209c6b53cc0eee0a81ff883ecf7ec93262bb9b79 /src/utils/parse.py | |
| parent | strip HTML from RSS entry titles (diff) | |
| signature | ||
refactor multi-line-to-line normalisation to utils.parse.line_normalise(), use it in rss.py
closes #174
Diffstat (limited to 'src/utils/parse.py')
| -rw-r--r-- | src/utils/parse.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils/parse.py b/src/utils/parse.py index 65d0552b..b53b9595 100644 --- a/src/utils/parse.py +++ b/src/utils/parse.py @@ -1,4 +1,5 @@ import io, typing +from src import utils COMMENT_TYPES = ["#", "//"] def hashflags(filename: str @@ -79,3 +80,7 @@ def try_int(s: str) -> typing.Optional[int]: return int(s) except ValueError: return None + +def line_normalise(s: str) -> str: + lines = list(filter(None, [line.strip() for line in s.split("\n")])) + return " ".join(line.replace(" ", " ") for line in lines) |
