GitHub | PyPI | Documentation | Issues | Changelog
linesep provides basic functions & classes for reading, writing, splitting, & joining text with custom separators that can occur either before, between, or after the segments they separate.
Installation
linesep requires Python 3.10 or higher. Just use pip for Python 3 (You have pip, right?) to install:
python3 -m pip install linesep
Examples
Reading sections separated by a “---” line:
with open('text.txt') as fp:
for entry in linesep.read_separated(fp, '\n---\n'):
...
Parsing output from find -print0:
find = subprocess.Popen(
['find', '/', '-some', '-complicated', '-condition', '-print0'],
stdout=subprocess.PIPE,
)
for filepath in linesep.read_terminated(find.stdout, '\0'):
...
A poor man’s JSON Text Sequence parser:
for entry in linesep.read_preceded(fp, '\x1E'):
try:
obj = json.loads(entry)
except ValueError:
pass
else:
yield obj
Read from a text file one paragraph at a time:
with open("my-novel.txt") as fp:
for paragraph in linesep.read_paragraphs(fp):
...
Split input from an anyio.TextReceiveStream on newlines:
async with anyio.TextReceiveStream( ... ) as stream:
splitter = linesep.UnicodeNewlineSplitter()
async for line in splitter.aitersplit(stream):
print(line)
Metadata
Release files for linesep 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| linesep-0.5.2.tar.gz | 21.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linesep-0.5.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.2 kB
Release files / linesep-0.5.2.tar.gz
| Download URL | linesep-0.5.2.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b908866710fbec8bb4ce5f0663bb8c7ad9fe38ba79d1692801d085a6229a4a88
|
|
BLAKE2b-256 checksum How to use checksums |
160714238dca74ad75d3d8363220692d6c6d102f681e926fdd262665311b0282
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / linesep-0.5.2-py3-none-any.whl
| Download URL | linesep-0.5.2-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f98281118442bce3739bea460eb4f0075e828aeac2dff9e477edc962ec6dff39
|
|
BLAKE2b-256 checksum How to use checksums |
6359f9280f1503e40b3529b667a7f8e96aa43e3be1ffa4c7514c9993d567c8bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|