High-performance line ending normalization for Python.
Project description
eolify
High-performance line ending normalization for Python, powered by Rust.
eolify provides fast and memory-efficient conversion between LF (\n) and CRLF (\r\n) line endings for text, files, and streams.
Features
- Fast Rust implementation
- Supports LF and CRLF normalization
- Memory-efficient file processing
- Cross-platform
- Typed API with Python type hints
Installation
pip install eolify
Pre-built wheels are available for common platforms, so a Rust toolchain is usually not required.
Quick Start
Normalize text
import eolify
text = "hello\r\nworld\r\n"
normalized = eolify.normalize_text(
text,
eolify.Mode.LF,
)
print(repr(normalized))
# 'hello\nworld\n'
Normalize a file
import eolify
eolify.normalize_file(
"input.txt",
"output.txt",
eolify.Mode.LF,
)
By default, the destination file must not already exist.
eolify.normalize_file(
"input.txt",
"output.txt",
eolify.Mode.LF,
overwrite=True,
)
Normalize a stream
import eolify
with open("input.txt", "rb") as source:
with open("output.txt", "wb") as destination:
eolify.normalize_stream(
source,
destination,
eolify.Mode.LF,
)
The source can also be a read callback and the destination can be a write callback.
import eolify
chunks = [b"hello\r\n", b"world\r\n", b""]
output = bytearray()
def read(size: int) -> bytes:
return chunks.pop(0)
def write(data: bytes) -> int:
output.extend(data)
return len(data)
eolify.normalize_stream(read, write, eolify.Mode.LF)
print(bytes(output))
# b'hello\nworld\n'
API
normalize_text(text, mode) -> str
Normalize line endings in a string.
Parameters:
text: Input text.mode:Mode.LForMode.CRLF.
Returns:
- The normalized string.
normalize_file(source, destination, mode, overwrite=False) -> None
Normalize line endings while copying one file to another.
Parameters:
source: Source file path.destination: Destination file path.mode:Mode.LForMode.CRLF.overwrite: Whether an existing destination file may be replaced.
normalize_stream(source, destination, mode) -> None
Normalize line endings while copying from one binary source to another.
Parameters:
source: Binary file-like object withread(size) -> bytes, or a read callback with the same signature.destination: Binary file-like object withwrite(data) -> int, or a write callback with the same signature. If a destination object providesflush(), it is called after copying.mode:Mode.LForMode.CRLF.
Modes
eolify.Mode.LF
eolify.Mode.CRLF
Why eolify?
Python's built-in newline handling is often sufficient, but there are situations where explicit normalization is desirable:
- Converting files between platforms
- Preparing source archives
- Processing generated files
- Build and CI pipelines
- Working with mixed line endings
eolify uses the same Rust implementation as the eolify crate, providing predictable
and efficient normalization behavior.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eolify-0.1.6.tar.gz.
File metadata
- Download URL: eolify-0.1.6.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64a95fef6aa1c29b460b191bf49cbbdbba747229018172a885de42edd296844a
|
|
| MD5 |
99be3f0a8a72f6124b168bc16b117acc
|
|
| BLAKE2b-256 |
fb4b4f39ab88efcaec16193d0b95136ada4879da1c1bed6e2ff5f6f122d6eda1
|
Provenance
The following attestation bundles were made for eolify-0.1.6.tar.gz:
Publisher:
publish.yml on cygnus9/eolify-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eolify-0.1.6.tar.gz -
Subject digest:
64a95fef6aa1c29b460b191bf49cbbdbba747229018172a885de42edd296844a - Sigstore transparency entry: 1822367616
- Sigstore integration time:
-
Permalink:
cygnus9/eolify-py@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/cygnus9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file eolify-0.1.6-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: eolify-0.1.6-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 127.0 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4de6ed629a7f7f8e7b01774fa4316da00a70646516ee0c2decbcb3d5396c36e
|
|
| MD5 |
2498a068a5099e4484a09fd0465c537e
|
|
| BLAKE2b-256 |
3830cd6d0804ac448010683572b5656a1c01c966a0600b7b1f564521bcc233e1
|
Provenance
The following attestation bundles were made for eolify-0.1.6-cp39-abi3-win_amd64.whl:
Publisher:
publish.yml on cygnus9/eolify-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eolify-0.1.6-cp39-abi3-win_amd64.whl -
Subject digest:
a4de6ed629a7f7f8e7b01774fa4316da00a70646516ee0c2decbcb3d5396c36e - Sigstore transparency entry: 1822367628
- Sigstore integration time:
-
Permalink:
cygnus9/eolify-py@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/cygnus9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file eolify-0.1.6-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: eolify-0.1.6-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 248.5 kB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e70a870103f94dc580e06a0927e3218fbd32e5d504e50a90c290477afcd5d675
|
|
| MD5 |
c0e319589d1800007f556b96b6a7f7f9
|
|
| BLAKE2b-256 |
886643d0db69d83f489383d51bb926aade8042781504e819e266d5a966938847
|
Provenance
The following attestation bundles were made for eolify-0.1.6-cp39-abi3-manylinux_2_34_x86_64.whl:
Publisher:
publish.yml on cygnus9/eolify-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eolify-0.1.6-cp39-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
e70a870103f94dc580e06a0927e3218fbd32e5d504e50a90c290477afcd5d675 - Sigstore transparency entry: 1822367643
- Sigstore integration time:
-
Permalink:
cygnus9/eolify-py@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/cygnus9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file eolify-0.1.6-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: eolify-0.1.6-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 220.4 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f73eda09ef57985e4eda0cecdd0d81726bf2c12f504eb28671ba7cec85d567d
|
|
| MD5 |
823fc383b4d6a908fe6c96c1122ebf72
|
|
| BLAKE2b-256 |
114d8ee131b8dfef9e18590d5dc44ab74dbc8d6d90ee8099c440282ead4ae61e
|
Provenance
The following attestation bundles were made for eolify-0.1.6-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
publish.yml on cygnus9/eolify-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eolify-0.1.6-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
8f73eda09ef57985e4eda0cecdd0d81726bf2c12f504eb28671ba7cec85d567d - Sigstore transparency entry: 1822367659
- Sigstore integration time:
-
Permalink:
cygnus9/eolify-py@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/cygnus9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f627926b6a11138b6eb78e7f2ad5bfea34cb0ff6 -
Trigger Event:
push
-
Statement type: