Ensure only human readable text files are in a directory.
Project description
Text Only Scanner 📝🔍
text_only_scanner helps teams ensure only human-readable text files pass validation. It
scans files (or directories) and rejects anything editors would struggle to open or read —
including binary files, files containing many control characters, and printable-but-high-entropy
blobs (e.g., encoded/encrypted payloads). 🚫🔒
Objective 🎯
Prevent non-human-readable files from slipping into pipelines or tests. The library flags files that are likely binary, contain unusual control characters, or appear to be encoded or encrypted text that isn't meant to be read directly. This keeps downstream tooling and review processes clean and predictable. ✅
Use Cases
- Detect accidental binary outputs in repositories and CI. 🧪
- Block files that hide encoded/encrypted content where plain text is expected. 🔐
- Serve as a pre-commit or CI gate to ensure only code are in the pipeline , not access/secret keys or tokens or binary files. ⛔️➡️✅
Usage
From Python:
from text_only_scanner.detector import is_text_file, filter_text_files
print(is_text_file("somefile.txt"))
accepted, rejected = filter_text_files(["a.txt", "b.bin"])
print("accepted:", accepted)
print("rejected:", rejected)
Command-line (module):
python -m text_only_scanner.cli file1.txt file2.bin
# prints accepted files to stdout, rejected to stderr and exits non-zero if any rejected
Notes:
- The detector combines several heuristics: NUL bytes, control-character ratios, printable vs letter ratios, and Shannon entropy to identify suspicious files. It is conservative — intended to reduce false negatives while keeping false positives low. ⚖️
Recursive usage:
# Recurse into directories and check all files inside
python -m text_only_scanner.cli -r pass_folder fail_folder
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 text_only_scanner-0.1.1.tar.gz.
File metadata
- Download URL: text_only_scanner-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3aef7cde3a27dbef8ff070106fac513e2dca7f4c560c395f0e7040d8dba319a
|
|
| MD5 |
69a1c6a21334ae389da8ecaaf19239e7
|
|
| BLAKE2b-256 |
a9cafdda366cc619d98a3d8c47e51ddbd94251117583ecd0231ade1256a54a13
|
File details
Details for the file text_only_scanner-0.1.1-py3-none-any.whl.
File metadata
- Download URL: text_only_scanner-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43ec0bc21b5be424dc4eb8006ac1e891aaa6ad607d2193073427e06b40c9c016
|
|
| MD5 |
03c570159ea8178021cb41ea847be0ec
|
|
| BLAKE2b-256 |
837a14dfea9aec7f4def72f30fa3d270de0e6eb9170ded5ba676e9b6973cfad9
|