binaryornot Package

binaryornot Package

check Module

binaryornot.check

Main code for checking if a file is binary or text.

binaryornot.check.is_binary(filename)[source]
Parameters:filename – File to check.
Returns:True if it’s a binary file, otherwise False.

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]
Parameters:bytes – A chunk of bytes to check.
Returns:True if appears to be a binary, otherwise False.
binaryornot.helpers.print_as_hex(s)[source]

Print a string as hex bytes.