A safe, atomic, and cross-platform way to handle text file I/O in Python.
Project description
splurge-safe-io
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 astrcontaining the entire normalized file content instead of alist[str]of lines. UseSafeTextFileReader.readlines()to get a list of lines.
See docs/README-DETAILS.md for a complete guide and usage examples.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 splurge_safe_io-2025.1.1.tar.gz.
File metadata
- Download URL: splurge_safe_io-2025.1.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
780e10c86f7f5819fa13784e830afb19f28c970fee45850285ed9f3d9953ee6d
|
|
| MD5 |
3238a6ff1c2cd03821067d4f2de62c3d
|
|
| BLAKE2b-256 |
c593efda1d104eef202b10a28c3d892c3de423849056546e2d911d5e128dad62
|
File details
Details for the file splurge_safe_io-2025.1.1-py3-none-any.whl.
File metadata
- Download URL: splurge_safe_io-2025.1.1-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bf88940a9cdad95f247790a6fcc389378874fed81c22dd5aff9122b68776e6f
|
|
| MD5 |
5427f82bad793a0785343cbe08ba04cb
|
|
| BLAKE2b-256 |
61b9ccccd6277016126a47244ffaac98fca846b144c67309c9f4ec0c4c823aa3
|