Debian Codegraph @

/

debian binaryornot 0.4.4+git20230412.ac4f56e+dfsg-2debian python3-binaryornot python binaryornot 0.4.4 cssdebianinijavascriptjsonluamakemakefilepythonpythonshellxmlyaml 29 files · 236 symbols
View dependency graph

Depends on

README (full)

BinaryOrNot

:target: https://pypi.python.org/pypi/binaryornot

:target: http://binaryornot.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

 Updates

Ultra-lightweight pure Python package to guess whether a file is binary or text, using a heuristic similar to Perl's `pp_fttext` and its analysis by @eliben.

Status

It works, and people are using this package in various places. But it doesn't cover all edge cases yet.

The code could be improved. Pull requests welcome! As of now, it is based on these snippets, but that may change:

Features

Has tests for these file types:

  • Text: .txt, .css, .json, .svg, .js, .lua, .pl, .rst

  • Binary: .png, .gif, .jpg, .tiff, .bmp, .DS_Store, .eot, .otf, .ttf, .woff, .rgb

Has tests for numerous encodings.

Why?

You may be thinking, "I can write this in 2 lines of code?!"

It's actually not that easy. Here's a great article about how Perl's heuristic to guess file types works: http://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/

And that's just where we started. Over time, we've found more edge cases and our heuristic has gotten more complex.

Also, this package saves you from having to write and thoroughly test your code with all sorts of weird file types and encodings, cross-platform.

Builds

Linux (Ubuntu 12.04 LTS Server Edition 64 bit):

:target: https://travis-ci.org/audreyr/binaryornot

Windows (Windows Server 2012 R2 (x64)):

:target: https://ci.appveyor.com/project/audreyr/binaryornot

Credits

Creator

This project was created by Audrey Roy Greenfeld.

dir appveyor/
dir binaryornot/
dir debian/
dir docs/
dir tests/
file .gitignore
file .pep8
file .travis.yml
file AUTHORS.rst
file CONTRIBUTING.rst
file HISTORY.rst
file LICENSE
file MANIFEST.in
file README.rst
file appveyor.yml
file requirements_dev.txt
file setup.cfg
file setup.py
file tasks.py
file tox.ini