Browse Source

Remove unidecode dependency and use unicodedata instead

I found a way to remove the unidecode dependency without sacrificing
much by using unicodedata.normalize .
pull/2223/head
Antonio Larrosa 8 years ago
parent
commit
bf023e7dc0
  1. 6
      flask/helpers.py
  2. 1
      setup.py
  3. 1
      tox.ini

6
flask/helpers.py

@ -14,6 +14,7 @@ import sys
import pkgutil import pkgutil
import posixpath import posixpath
import mimetypes import mimetypes
import unicodedata
from time import time from time import time
from zlib import adler32 from zlib import adler32
from threading import RLock from threading import RLock
@ -41,7 +42,6 @@ from .signals import message_flashed
from .globals import session, _request_ctx_stack, _app_ctx_stack, \ from .globals import session, _request_ctx_stack, _app_ctx_stack, \
current_app, request current_app, request
from ._compat import string_types, text_type from ._compat import string_types, text_type
from unidecode import unidecode
# sentinel # sentinel
@ -536,7 +536,9 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
raise TypeError('filename unavailable, required for ' raise TypeError('filename unavailable, required for '
'sending as attachment') 'sending as attachment')
filename_dict = { filename_dict = {
'filename': unidecode(text_type(attachment_filename)), 'filename': (unicodedata.normalize('NFKD',
text_type(attachment_filename)).encode('ascii',
'ignore')),
'filename*': "UTF-8''%s" % url_quote(attachment_filename)} 'filename*': "UTF-8''%s" % url_quote(attachment_filename)}
headers.add('Content-Disposition', 'attachment', headers.add('Content-Disposition', 'attachment',
**filename_dict) **filename_dict)

1
setup.py

@ -75,7 +75,6 @@ setup(
'Jinja2>=2.4', 'Jinja2>=2.4',
'itsdangerous>=0.21', 'itsdangerous>=0.21',
'click>=2.0', 'click>=2.0',
'unidecode',
], ],
classifiers=[ classifiers=[
'Development Status :: 4 - Beta', 'Development Status :: 4 - Beta',

1
tox.ini

@ -27,7 +27,6 @@ deps=
devel: git+https://github.com/pallets/itsdangerous.git devel: git+https://github.com/pallets/itsdangerous.git
devel: git+https://github.com/jek/blinker.git devel: git+https://github.com/jek/blinker.git
simplejson: simplejson simplejson: simplejson
unidecode
[testenv:docs] [testenv:docs]
deps = sphinx deps = sphinx

Loading…
Cancel
Save