From 30caccbaaf79c125298ae93aea6c4ad64741828f Mon Sep 17 00:00:00 2001 From: Mathias Markl Date: Wed, 25 Jul 2018 11:00:55 +0200 Subject: [PATCH] update --- muk_utils/__manifest__.py | 2 +- muk_utils/tools/utils_os.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/muk_utils/__manifest__.py b/muk_utils/__manifest__.py index 3ff7757..10c354d 100644 --- a/muk_utils/__manifest__.py +++ b/muk_utils/__manifest__.py @@ -20,7 +20,7 @@ { "name": "MuK Utils", "summary": """Utility Features""", - "version": '11.0.1.0.11', + "version": '11.0.1.0.12', "category": 'Extra Tools', "license": "AGPL-3", "website": "https://www.mukit.at", diff --git a/muk_utils/tools/utils_os.py b/muk_utils/tools/utils_os.py index e68249d..1501bf9 100644 --- a/muk_utils/tools/utils_os.py +++ b/muk_utils/tools/utils_os.py @@ -49,12 +49,13 @@ def unique_name(name, names, escape_suffix=False): return name def get_extension(binary, filename, mimetype): + extension = None if not mimetype and not filename: mimetype = guess_mimetype(binary, default=False) if not mimetype and filename: 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 \ No newline at end of file + 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 \ No newline at end of file