| 1 |
Metadata-Version: 2.0 |
| 2 |
Name: binaryornot |
| 3 |
Version: 0.4.4 |
| 4 |
Summary: Ultra-lightweight pure Python package to check if a file is binary or text. |
| 5 |
Home-page: https://github.com/audreyr/binaryornot |
| 6 |
Author: Audrey Roy Greenfeld |
| 7 |
Author-email: [email protected] |
| 8 |
License: BSD |
| 9 |
Keywords: binaryornot |
| 10 |
Platform: UNKNOWN |
| 11 |
Classifier: Development Status :: 5 - Production/Stable |
| 12 |
Classifier: Intended Audience :: Developers |
| 13 |
Classifier: License :: OSI Approved :: BSD License |
| 14 |
Classifier: Natural Language :: English |
| 15 |
Classifier: Programming Language :: Python :: 2 |
| 16 |
Classifier: Programming Language :: Python :: 2.7 |
| 17 |
Classifier: Programming Language :: Python :: 3 |
| 18 |
Classifier: Programming Language :: Python :: 3.3 |
| 19 |
Classifier: Programming Language :: Python :: 3.4 |
| 20 |
Classifier: Programming Language :: Python :: 3.5 |
| 21 |
Classifier: Programming Language :: Python :: 3.6 |
| 22 |
Requires-Dist: chardet (>=3.0.2) |
| 23 |
|
| 24 |
============================= |
| 25 |
BinaryOrNot |
| 26 |
============================= |
| 27 |
|
| 28 |
.. image:: https://img.shields.io/pypi/v/binaryornot.svg?style=flat |
| 29 |
:target: https://pypi.python.org/pypi/binaryornot |
| 30 |
|
| 31 |
.. image:: https://readthedocs.org/projects/binaryornot/badge/?version=latest |
| 32 |
:target: http://binaryornot.readthedocs.io/en/latest/?badge=latest |
| 33 |
:alt: Documentation Status |
| 34 |
|
| 35 |
|
| 36 |
.. image:: https://pyup.io/repos/github/audreyr/binaryornot/shield.svg |
| 37 |
:target: https://pyup.io/repos/github/audreyr/binaryornot/ |
| 38 |
:alt: Updates |
| 39 |
|
| 40 |
Ultra-lightweight pure Python package to guess whether a file is binary or text, |
| 41 |
using a heuristic similar to Perl's `pp_fttext` and its analysis by @eliben. |
| 42 |
|
| 43 |
* Free software: BSD license |
| 44 |
* Documentation: https://binaryornot.readthedocs.io |
| 45 |
|
| 46 |
Status |
| 47 |
------ |
| 48 |
|
| 49 |
It works, and people are using this package in various places. But it doesn't cover all edge cases yet. |
| 50 |
|
| 51 |
The code could be improved. Pull requests welcome! As of now, it is based on these snippets, but that may change: |
| 52 |
|
| 53 |
* http://stackoverflow.com/questions/898669/how-can-i-detect-if-a-file-is-binary-non-text-in-python |
| 54 |
* http://stackoverflow.com/questions/1446549/how-to-identify-binary-and-text-files-using-python |
| 55 |
* http://code.activestate.com/recipes/173220/ |
| 56 |
* http://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/ |
| 57 |
|
| 58 |
Features |
| 59 |
-------- |
| 60 |
|
| 61 |
Has tests for these file types: |
| 62 |
|
| 63 |
* Text: .txt, .css, .json, .svg, .js, .lua, .pl, .rst |
| 64 |
* Binary: .png, .gif, .jpg, .tiff, .bmp, .DS_Store, .eot, .otf, .ttf, .woff, .rgb |
| 65 |
|
| 66 |
Has tests for numerous encodings. |
| 67 |
|
| 68 |
Why? |
| 69 |
---- |
| 70 |
|
| 71 |
You may be thinking, "I can write this in 2 lines of code?!" |
| 72 |
|
| 73 |
It's actually not that easy. Here's a great article about how Perl's |
| 74 |
heuristic to guess file types works: http://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/ |
| 75 |
|
| 76 |
And that's just where we started. Over time, we've found more edge cases and |
| 77 |
our heuristic has gotten more complex. |
| 78 |
|
| 79 |
Also, this package saves you from having to write and thoroughly test |
| 80 |
your code with all sorts of weird file types and encodings, cross-platform. |
| 81 |
|
| 82 |
Builds |
| 83 |
------ |
| 84 |
|
| 85 |
Linux (Ubuntu 12.04 LTS Server Edition 64 bit): |
| 86 |
|
| 87 |
.. image:: https://img.shields.io/travis/audreyr/binaryornot/master.svg |
| 88 |
:target: https://travis-ci.org/audreyr/binaryornot |
| 89 |
|
| 90 |
Windows (Windows Server 2012 R2 (x64)): |
| 91 |
|
| 92 |
.. image:: https://img.shields.io/appveyor/ci/audreyr/binaryornot/master.svg |
| 93 |
:target: https://ci.appveyor.com/project/audreyr/binaryornot |
| 94 |
|
| 95 |
Credits |
| 96 |
------- |
| 97 |
|
| 98 |
* Special thanks to Eli Bendersky (@eliben) for his writeup explaining the heuristic and his implementation, which this is largely based on. |
| 99 |
* Source code from the portion of Perl's `pp_fttext` that checks for textiness: https://github.com/Perl/perl5/blob/v5.23.1/pp_sys.c#L3527-L3587 |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
History |
| 105 |
------- |
| 106 |
|
| 107 |
0.4.4 (2017-04-13) |
| 108 |
~~~~~~~~~~~~~~~~~~ |
| 109 |
|
| 110 |
* Notify users for file i/o issues. Thanks @lukehinds! |
| 111 |
|
| 112 |
|
| 113 |
0.4.3 (2017-04-13) |
| 114 |
~~~~~~~~~~~~~~~~~~ |
| 115 |
|
| 116 |
* Restricted chardet to anything 3.0.2 or higher due to https://github.com/chardet/chardet/issues/113. Thanks @dan-blanchard for the quick fix! |
| 117 |
|
| 118 |
0.4.2 (2017-04-12) |
| 119 |
~~~~~~~~~~~~~~~~~~ |
| 120 |
|
| 121 |
* Restricted chardet to anything under 3.0 due to https://github.com/chardet/chardet/issues/113 |
| 122 |
* Added pyup badge |
| 123 |
* Added utilities for pushing new versions up |
| 124 |
|
| 125 |
0.4.0 (2015-08-21) |
| 126 |
~~~~~~~~~~~~~~~~~~ |
| 127 |
|
| 128 |
* Enhanced detection for some binary streams and UTF texts. (#10, 11) Thanks `@pombredanne`_. |
| 129 |
* Set up Appveyor for continuous testing on Windows. Thanks `@pydanny`_. |
| 130 |
* Update link to Perl source implementation. (#9) Thanks `@asmeurer`_ `@pombredanne`_ `@audreyr`_. |
| 131 |
* Handle UnicodeDecodeError in check. (#12) Thanks `@DRMacIver`_. |
| 132 |
* Add very simple Hypothesis based tests. (#13) Thanks `@DRMacIver`_. |
| 133 |
* Use setup to determine requirements and remove redundant requirements.txt. (#14) Thanks `@hackebrot`_. |
| 134 |
* Add documentation status badge to README.rst. (#15) Thanks `@hackebrot`_. |
| 135 |
* Run tox in travis.yml. Add pypy and Python 3.4 to tox environments. (#16) Thanks `@hackebrot`_ `@pydanny`_. |
| 136 |
* Handle LookupError when detecting encoding. (#17) Thanks `@DRMacIver`_. |
| 137 |
|
| 138 |
|
| 139 |
.. _`@pombredanne`: https://github.com/pombredanne |
| 140 |
.. _`@pydanny`: https://github.com/pydanny |
| 141 |
.. _`@asmeurer`: https://github.com/asmeurer |
| 142 |
.. _`@audreyr`: https://github.com/audreyr |
| 143 |
.. _`@DRMacIver`: https://github.com/DRMacIver |
| 144 |
.. _`@hackebrot`: https://github.com/hackebrot |
| 145 |
|
| 146 |
0.3.0 (2014-05-05) |
| 147 |
~~~~~~~~~~~~~~~~~~ |
| 148 |
|
| 149 |
* Include tests, docs in source package. (#6) Thanks `@vincentbernat`_. |
| 150 |
* Drop unnecessary shebangs and executable bits. (#8) Thanks `@scop`_. |
| 151 |
* Generate string of printable extended ASCII bytes only once. (#7) Thanks `@scop`_. |
| 152 |
* Make number of bytes to read parametrizable. (#7) Thanks `@scop`_. |
| 153 |
|
| 154 |
.. _`@vincentbernat`: https://github.com/vincentbernat |
| 155 |
.. _`@scop`: https://github.com/scop |
| 156 |
|
| 157 |
0.2.0 (2013-09-22) |
| 158 |
~~~~~~~~~~~~~~~~~~ |
| 159 |
|
| 160 |
* Complete rewrite of everything. Thanks `@ncoghlan`_. |
| 161 |
|
| 162 |
.. _`@ncoghlan`: https://github.com/ncoghlan |
| 163 |
|
| 164 |
0.1.1 (2013-08-17) |
| 165 |
~~~~~~~~~~~~~~~~~~ |
| 166 |
|
| 167 |
* Tests pass under Python 2.6, 2.7, 3.3, PyPy. |
| 168 |
|
| 169 |
|
| 170 |
0.1.0 (2013-08-17) |
| 171 |
~~~~~~~~~~~~~~~~~~ |
| 172 |
|
| 173 |
* First release on PyPI. |
| 174 |
|
| 175 |
|