code: def binary_guesser(handle, num_bytes=512):
      
  
      text_chars = ''.join(map(chr, range(32, 127))) + '\n\r\t\b'
      byte_chars = text_chars.encode()
      handle_location = handle.tell()
      first_block = handle.read(num_bytes)
      if type(first_block) is str:
          first_block = first_block.encode()
      filtered_block = first_block.translate(None, delete=byte_chars)
      handle.seek(handle_location)  # Return to original handle location
      if float(len(filtered_block)) / float(len(first_block)) > 0.30:
          pass  # File is likely binary
      else:
          msg = '{0} is probably not a binary file'.format(handle.name)
          raise FormatError(message=msg)
docs: Raise error if file not likely binary
  
      Guesses if a file is binary, raises error if file is not likely binary,
      then returns to location in file when handle passed to binary_guesser.
  
      Args:
          handle (file): File handle of file thought to be binary
  
          num_bytes (int): Bytes of file to read to guess binary, more bytes
                           is often better but takes longer
  
      Raises:
          FormatError: Error raised if file is not likely binary
  
      Example:
          The following example demonstrate how to use binary_guesser.
          Note: These doctests will not pass, examples are only in doctest
          format as per convention. bio_utils uses pytests for testing.
  
          >>> binary_guesser(open('test.binary'))