summaryrefslogtreecommitdiffstats
path: root/Lib/mimetypes.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/mimetypes.py')
-rw-r--r--Lib/mimetypes.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index a909366..5784e23 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -148,10 +148,8 @@ class MimeTypes:
Return value is a list of strings giving the possible filename
extensions, including the leading dot ('.'). The extension is not
- guaranteed to have been associated with any particular data
- stream, but would be mapped to the MIME type `type' by
- guess_type(). If no extension can be guessed for `type', None
- is returned.
+ guaranteed to have been associated with any particular data stream,
+ but would be mapped to the MIME type `type' by guess_type().
Optional `strict' argument when false adds a bunch of commonly found,
but non-standard types.
@@ -162,8 +160,7 @@ class MimeTypes:
for ext in self.types_map_inv[False].get(type, []):
if ext not in extensions:
extensions.append(ext)
- if len(extensions):
- return extensions
+ return extensions
def guess_extension(self, type, strict=True):
"""Guess the extension for a file based on its MIME type.
@@ -179,9 +176,9 @@ class MimeTypes:
but non-standard types.
"""
extensions = self.guess_all_extensions(type, strict)
- if extensions is not None:
- extensions = extensions[0]
- return extensions
+ if not extensions:
+ return None
+ return extensions[0]
def read(self, filename, strict=True):
"""