Skip to main content

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.LF, Mode.CRLF, "\n" or "\r\n".

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.LF, Mode.CRLF, "\n" or "\r\n".
  • 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 with read(size) -> bytes, or a read callback with the same signature.
  • destination: Binary file-like object with write(data) -> int, or a write callback with the same signature. If a destination object provides flush(), it is called after copying.
  • mode: Mode.LF, Mode.CRLF, "\n" or "\r\n".

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

eolify-0.1.7.tar.gz (9.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

eolify-0.1.7-cp39-abi3-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.9+Windows x86-64

eolify-0.1.7-cp39-abi3-manylinux_2_34_x86_64.whl (250.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

eolify-0.1.7-cp39-abi3-macosx_11_0_arm64.whl (223.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file eolify-0.1.7.tar.gz.

File metadata

  • Download URL: eolify-0.1.7.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for eolify-0.1.7.tar.gz
Algorithm Hash digest
SHA256 27444e20c244236141d762c79251a7ef8b2837513d4bdbb881ede28b99726d33
MD5 99a85296971de1c67a7859d6bf31473c
BLAKE2b-256 6c1ecfe5f3dc51d387b82a2aaeb417fc4650357ffbd6f7760ab339da6b00a883

See more details on using hashes here.

Provenance

The following attestation bundles were made for eolify-0.1.7.tar.gz:

Publisher: publish.yml on cygnus9/eolify-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eolify-0.1.7-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: eolify-0.1.7-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 129.6 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

Hashes for eolify-0.1.7-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9cc1de60435ff13f849566ef28e10a981125e9c5b810cb45a1b168e7614fe4ff
MD5 23d5b3804b1af1b644ed5409170a486c
BLAKE2b-256 b2fe2a8795957bd670fb8545bedb9baaae7784df6bc6220fa4372af678622ac6

See more details on using hashes here.

Provenance

The following attestation bundles were made for eolify-0.1.7-cp39-abi3-win_amd64.whl:

Publisher: publish.yml on cygnus9/eolify-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eolify-0.1.7-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for eolify-0.1.7-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4a0bebb48bfdf77f1c22c0489b9bbdb14ffbb6727f2fb5f7d629baf2cbeebbea
MD5 1ccdbb248940c562d43c426b43326a05
BLAKE2b-256 166e99d482a919cc47a88936b792d12d5c53578689c04be7a48e5e5ddad145fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for eolify-0.1.7-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on cygnus9/eolify-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eolify-0.1.7-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: eolify-0.1.7-cp39-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 223.1 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

Hashes for eolify-0.1.7-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12df54f2d1ac00e840bda982aeb80f2026cad0563ed6112dd79555a24665b157
MD5 fa46f946a66c1956e48c571a9da1bb8a
BLAKE2b-256 675942dd608c37ca4a107ffad1c7e37cbf7f992d7e0623b3cdb0a8132dd1e67b

See more details on using hashes here.

Provenance

The following attestation bundles were made for eolify-0.1.7-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on cygnus9/eolify-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page