pkgcheck.utils module¶
Various miscellaneous utility functions.
- pkgcheck.utils.is_binary(path, blocksize=1024)[source]¶
Check if a given file is binary or not.
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:
path – Path to a file to check.
blocksize – Amount of bytes to read for determination.
- Returns:
True if appears to be a binary, otherwise False.