Main code for checking if a file is binary or text. """
import logging
from .helpers import get_starting_chunk, is_binary_string
logger = logging.getLogger(__name__)
def is_binary(filename): """
:param filename: File to check.
:returns: Trueif it's a binary file, otherwise False. """
logger.debug('is_binary: %(filename)r', locals())
# Check if the file extension is in a list of known binary types
binary_extensions = ['.pyc', ] for ext in binary_extensions: if filename.endswith(ext): returnTrue
# Check if the starting chunk is a binary string
chunk = get_starting_chunk(filename) return is_binary_string(chunk)
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.