Browse Source

implemented asked changes

pull/2115/head
José Oliveira 8 years ago
parent
commit
6a9b48ed2d
  1. 15
      flask/helpers.py

15
flask/helpers.py

@ -14,6 +14,7 @@ import sys
import pkgutil import pkgutil
import posixpath import posixpath
import mimetypes import mimetypes
import warnings
from time import time from time import time
from zlib import adler32 from zlib import adler32
from threading import RLock from threading import RLock
@ -504,8 +505,7 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
a :class:`~datetime.datetime` or timestamp. a :class:`~datetime.datetime` or timestamp.
If a file was passed, this overrides its mtime. If a file was passed, this overrides its mtime.
""" """
import warnings if isinstance(filename_or_fp, string_types):
if type(filename_or_fp) is str:
if not is_ascii(filename_or_fp): if not is_ascii(filename_or_fp):
warnings.warn("Non-ASCII filename is being used in send_file", UnicodeWarning) warnings.warn("Non-ASCII filename is being used in send_file", UnicodeWarning)
@ -964,15 +964,12 @@ def total_seconds(td):
""" """
return td.days * 60 * 60 * 24 + td.seconds return td.days * 60 * 60 * 24 + td.seconds
def is_ascii(string_to_test): def is_ascii(string):
"""Returns if a string object is fully ASCII encoded. """Returns if a string object is fully ASCII encoded.
:param string string_to_test: the string to be evaluated :param string string: the string to be evaluated
:returns: True if string_to_test is fully ASCII encoded, False if not :returns: True if string is fully ASCII encoded, False if not
:rtype: boolean :rtype: boolean
""" """
if all(ord(char) < 128 for char in string_to_test): return all(ord(char) < 128 for char in string):
return True
else:
return False

Loading…
Cancel
Save