Registry / serialization / isbinary

isbinary

JSON →
library1.0.1pypypi✓ verified 84d ago

A lightweight pure Python package to check if a file is binary or text (fork of binaryornot). Current version 1.0.1, released April 2023. Uses heuristic scanning of a configurable chunk of bytes.

pip install isbinary
INSTALL
IMPORT
SIG · ISBINARY
I
isbinary
serializationpythonv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

is_binary_file
from isbinary import is_binary_file
from binaryornot.check import is_binary
Old import from the original binaryornot library; v1.0.0 broke compatibility and renamed the function.

Basic usage to detect binary vs text file.

from isbinary import is_binary_file result = is_binary_file('path/to/file') print(result) # True if binary, False if text # Or via CLI: python -m isbinary path/to/file
Debug
Known issues
breakingIn v1.0.0 the package name changed from binaryornot to isbinary. All imports must be updated.
fix
Replace `from binaryornot.check import is_binary` with `from isbinary import is_binary_file`.
affects: ≥1.0.0
breakingThe function name changed from `is_binary` to `is_binary_file` in v1.0.0.
fix
Change all calls from `is_binary(path)` to `is_binary_file(path)`.
affects: ≥1.0.0
gotchaThe default chunk size increased from 1024 to 2048 bytes. This may affect detection of very small files or performance.
fix
If needed, adjust chunk size with the `chunk_size` parameter: `is_binary_file(path, chunk_size=1024)`.
affects: ≥1.0.0
gotchaPython 2 support was removed. Only Python 3.8+ is supported.
fix
Ensure you run on Python 3.8 or later.
affects: ≥1.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'binaryornot'
The old package binaryornot is replaced by isbinary.
fix
Install isbinary and update imports: `from isbinary import is_binary_file`.
AttributeError: module 'binaryornot.check' has no attribute 'is_binary'
The package was renamed; import path is different.
fix
Use `from isbinary import is_binary_file`.
ImportError: cannot import name 'is_binary' from 'isbinary'
Function was renamed from is_binary to is_binary_file in v1.0.0.
fix
Use `from isbinary import is_binary_file` and call `is_binary_file(path)`.
Upgrade
Version history
1.0.1latest on PyPI · released May 22, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
isbinary — pip install isbinary · libregistry