Skip to content

Commit

Permalink
Add new 'clean' function, extracted from 'yield_lines'.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 14, 2024
1 parent 1064e98 commit 98bd89f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jaraco/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import re
import textwrap

from typing import Iterable

try:
from importlib.resources import files # type: ignore
except ImportError: # pragma: nocover
Expand Down Expand Up @@ -554,7 +556,14 @@ def yield_lines(iterable):

@yield_lines.register(str)
def _(text):
return filter(_nonblank, map(str.strip, text.splitlines()))
return clean(text.splitlines())


def clean(lines: Iterable[str]):
"""
Yield non-blank, non-comment elements from lines.
"""
return filter(_nonblank, map(str.strip, lines))


def drop_comment(line):
Expand Down
1 change: 1 addition & 0 deletions newsfragments/+cefc5be5.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add new 'clean' function, extracted from 'yield_lines'.

0 comments on commit 98bd89f

Please sign in to comment.