Commit 64a8888e authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

new fallbackmimetype argument to guess_mimetype and encoding

parent 5a1b250c8405
......@@ -70,7 +70,8 @@ def guess_encoding(buffer, fallbackencoding=None):
return fallbackencoding or DEFAULT_ENCODING
def guess_mimetype_and_encoding(format=None, encoding=None, data=None,
filename=None, fallbackencoding=None):
filename=None, fallbackencoding=None,
fallbackmimetype=u'application/octet-stream'):
if format and format.split('/')[-1] in BINARY_ENCODINGS:
format = None # try to do better
if filename and not format:
......@@ -81,7 +82,7 @@ def guess_mimetype_and_encoding(format=None, encoding=None, data=None,
elif enc:
format = u'application/%s' % enc
else:
format = u'application/octet-stream'
format = fallbackmimetype
if not encoding and data and format and is_text_mimetype(format):
encoding = guess_encoding(data, fallbackencoding)
return format, encoding
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment