Skip to main content

A safe, atomic, and cross-platform way to handle text file I/O in Python.

Project description

splurge-safe-io

PyPI version Python versions License: MIT

CI Coverage Ruff mypy

A small, secure, and deterministic text file I/O helper library.

Key features

  • Deterministic newline normalization (LF) for text reads/writes.
  • Secure path validation utilities to avoid traversal and dangerous characters.
  • Streaming reader with incremental decoding and a safe fallback for tricky encodings.
  • Clear, small exception hierarchy for stable error handling.

Quick start

from splurge_safe_io.safe_text_file_reader import SafeTextFileReader
from splurge_safe_io.safe_text_file_writer import open_safe_text_writer

# Read lines
reader = SafeTextFileReader('data.csv')
rows = reader.readlines()

# Write via context manager
with open_safe_text_writer('out.txt') as buf:
    buf.write('\n'.join(['one','two','three']))

⚠️ BREAKING CHANGE for v2025.1.0: SafeTextFileReader.read() now returns a str containing the entire normalized file content instead of a list[str] of lines. Use SafeTextFileReader.readlines() to get a list of lines.

See docs/README-DETAILS.md for a complete guide and usage examples.

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

splurge_safe_io-2025.4.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

splurge_safe_io-2025.4.2-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file splurge_safe_io-2025.4.2.tar.gz.

File metadata

  • Download URL: splurge_safe_io-2025.4.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for splurge_safe_io-2025.4.2.tar.gz
Algorithm Hash digest
SHA256 0f3b6e9fb487049fbfa8b4a11c0783239a8b2dc9225f5e9ab01f8296d93332c2
MD5 b2e2089f3ab8cef609878a8cf9be26d0
BLAKE2b-256 7d069181e99ac60f972de02a1021b800e54d69a5ca1096f0446b53cd63d348f6

See more details on using hashes here.

File details

Details for the file splurge_safe_io-2025.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for splurge_safe_io-2025.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 02b5cb56b6f3cd0c7416a79e8da9f7497be48e333a7a29e45c777c057d3198b2
MD5 b702d5b5702ba6f6d43a75325ec8edab
BLAKE2b-256 edd2f7144977102ba95c436719522af282a1cf112316de148650032c99979b3c

See more details on using hashes here.

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