Skip to main content

Text-only file scanner

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 artifacts are text-friendly. ⛔️➡️✅

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

text_only_scanner-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

text_only_scanner-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file text_only_scanner-0.1.0.tar.gz.

File metadata

  • Download URL: text_only_scanner-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for text_only_scanner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 51724e7b8d341bddcc2c2543036b7b743f8710e81f2181e299637c41ab89708c
MD5 b3ace3541b100eefd9c53f52e5bd03e5
BLAKE2b-256 a2f612c0ea1950574413ac584a017dadcc43e47fb1759a3867b418eebada2fba

See more details on using hashes here.

File details

Details for the file text_only_scanner-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for text_only_scanner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44906d935053f40cc5b214aceb61fe91c1ca52c9e6d29a53abe644e5d486162c
MD5 42991d3145b8c360dbdc35ef59e67c67
BLAKE2b-256 b3478b41d21924fba912cb60b5fb04b9ffd36a2f1a9a655526dcaa33d660c44e

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