Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significantly reduce library footprint #1741

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,966 changes: 0 additions & 4,966 deletions requests/cacert.pem

Large diffs are not rendered by default.

67 changes: 3 additions & 64 deletions requests/packages/charade/__init__.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,5 @@
######################## BEGIN LICENSE BLOCK ########################
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################

__version__ = "1.0.3"
from sys import version_info

# We don't use any other decodings than UTF-8, so we can short circuit
# this one call and delete the rest of this bulky library in its entirety.

def detect(aBuf):
if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or
(version_info >= (3, 0) and not isinstance(aBuf, bytes))):
raise ValueError('Expected a bytes object, not a unicode object')

from . import universaldetector
u = universaldetector.UniversalDetector()
u.reset()
u.feed(aBuf)
u.close()
return u.result

def _description_of(path):
"""Return a string describing the probable encoding of a file."""
from charade.universaldetector import UniversalDetector

u = UniversalDetector()
for line in open(path, 'rb'):
u.feed(line)
u.close()
result = u.result
if result['encoding']:
return '%s: %s with confidence %s' % (path,
result['encoding'],
result['confidence'])
else:
return '%s: no result' % path


def charade_cli():
"""
Script which takes one or more file paths and reports on their detected
encodings

Example::

% chardetect.py somefile someotherfile
somefile: windows-1252 with confidence 0.5
someotherfile: ascii with confidence 1.0

"""
from sys import argv
for path in argv[1:]:
print(_description_of(path))

return {'encoding': 'utf-8'}
7 changes: 0 additions & 7 deletions requests/packages/charade/__main__.py

This file was deleted.

925 changes: 0 additions & 925 deletions requests/packages/charade/big5freq.py

This file was deleted.

42 changes: 0 additions & 42 deletions requests/packages/charade/big5prober.py

This file was deleted.

231 changes: 0 additions & 231 deletions requests/packages/charade/chardistribution.py

This file was deleted.

Loading