Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
logilab-mtconverter
Commits
082c3860e479
Commit
64a8888e
authored
Jul 09, 2009
by
Sylvain Thénault
Browse files
new fallbackmimetype argument to guess_mimetype and encoding
parent
5a1b250c8405
Changes
1
Hide whitespace changes
Inline
Side-by-side
__init__.py
View file @
082c3860
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment