isbinary Package¶
isbinary Package¶
- isbinary.__init__.get_starting_chunk(filename: Union[str, os.PathLike], /, *, chunk_len: int = 2028) bytes[source]¶
- Parameters
filename (Union[str, os.PathLike]) – File to open and get the first little chunk of.
chunk_len (int) – Number of bytes to read, default 2048.
- Returns
Starting chunk of bytes.
- Return type
- class isbinary.__init__.BinaryLikeliness(value)[source]¶
Bases:
enum.EnumAn enumeration.
- HIGH = 1¶
- MID = 2¶
- LOW = 3¶
- isbinary.__init__.is_likely_binary(bytes_to_check: bytes, /) isbinary.check.BinaryLikeliness[source]¶
- Parameters
bytes_to_check (bytes) – A chunk of bytes to check.
- Returns
True if is likely binary, False otherwise.
- Return type
- isbinary.__init__.is_binary_string(bytes_to_check: bytes, /) bool[source]¶
Uses a simplified version of the Perl detection algorithm, based roughly on Eli Bendersky’s translation to Python: https://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/
This is biased slightly more in favour of deeming files as text files than the Perl algorithm, since all ASCII compatible character sets are accepted as text, not just utf-8.
- isbinary.__init__.is_binary_file(filename: Union[str, os.PathLike], /, *, starting_chunk_len: int = 2028) bool[source]¶
- Parameters
filename (Union[str, os.PathLike]) – File to check.
starting_chunk_len (int) – Number of bytes to read, default 2048.
- Returns
True if it’s a binary file, otherwise False.
- Return type