Remove unidecode dependency and use unicodedata instead

I found a way to remove the unidecode dependency without sacrificing
much by using unicodedata.normalize .
This commit is contained in:
Antonio Larrosa 2017-03-30 17:32:21 +02:00
parent 6ef45f30ab
commit bf023e7dc0
3 changed files with 4 additions and 4 deletions

View file

@ -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)

View file

@ -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',

View file

@ -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