binaryornot Package¶
binaryornot
Package¶
check
Module¶
helpers
Module¶
binaryornot.helpers¶
Helper utilities used by BinaryOrNot.
-
binaryornot.helpers.
get_starting_chunk
(filename, length=1024)[source]¶ Parameters: - filename – File to open and get the first little chunk of.
- length – Number of bytes to read, default 1024.
Returns: Starting chunk of bytes.
-
binaryornot.helpers.
is_binary_string
(bytes_to_check)[source]¶ Uses a simplified version of the Perl detection algorithm, based roughly on Eli Bendersky’s translation to Python: http://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.
Parameters: bytes – A chunk of bytes to check. Returns: True if appears to be a binary, otherwise False.