Browse Source

update

pull/6/head
Mathias Markl 6 years ago
parent
commit
30caccbaaf
  1. 2
      muk_utils/__manifest__.py
  2. 11
      muk_utils/tools/utils_os.py

2
muk_utils/__manifest__.py

@ -20,7 +20,7 @@
{ {
"name": "MuK Utils", "name": "MuK Utils",
"summary": """Utility Features""", "summary": """Utility Features""",
"version": '11.0.1.0.11',
"version": '11.0.1.0.12',
"category": 'Extra Tools', "category": 'Extra Tools',
"license": "AGPL-3", "license": "AGPL-3",
"website": "https://www.mukit.at", "website": "https://www.mukit.at",

11
muk_utils/tools/utils_os.py

@ -49,12 +49,13 @@ def unique_name(name, names, escape_suffix=False):
return name return name
def get_extension(binary, filename, mimetype): def get_extension(binary, filename, mimetype):
extension = None
if not mimetype and not filename: if not mimetype and not filename:
mimetype = guess_mimetype(binary, default=False) mimetype = guess_mimetype(binary, default=False)
if not mimetype and filename: if not mimetype and filename:
mimetype = mimetypes.guess_type(urllib.request.pathname2url(filename))[0] mimetype = mimetypes.guess_type(urllib.request.pathname2url(filename))[0]
if mimetype and mimetype != 'application/octet-stream':
return mimetypes.guess_extension(mimetype)[1:].strip().lower()
elif filename:
return os.path.splitext(filename)[1][1:].strip().lower()
return None
if filename:
extension = os.path.splitext(filename)[1][1:].strip().lower()
if not extension and mimetype and mimetype != 'application/octet-stream':
extension = mimetypes.guess_extension(mimetype)[1:].strip().lower()
return extension
Loading…
Cancel
Save