Browse Source

update

pull/6/head
Mathias Markl 6 years ago
parent
commit
61309fd1e1
  1. 2
      muk_utils/__manifest__.py
  2. 17
      muk_utils/tools/utils_os.py

2
muk_utils/__manifest__.py

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

17
muk_utils/tools/utils_os.py

@ -18,7 +18,13 @@
###################################################################################
import os
import io
import base64
import shutil
import urllib
import logging
import tempfile
import mimetypes
_logger = logging.getLogger(__name__)
@ -38,3 +44,14 @@ def unique_name(name, names, escape_suffix=False):
suffix += 1
name = compute_name(name, suffix, escape_suffix)
return name
def get_extension(filename, mimetype):
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 not filename and mimetype:
return mimetypes.guess_extension(mimetype)[1:].strip().lower()
elif filename:
return os.path.splitext(filename)[1][1:].strip().lower()
return None
Loading…
Cancel
Save