Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(502)

Unified Diff: Lib/mimetypes.py

Issue 1043134: mimetypes.guess_extension('text/plain') == '.ksh' ???
Patch Set: Created 2 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/test/test_mimetypes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Lib/mimetypes.py
===================================================================
--- Lib/mimetypes.py (revisão 86582)
+++ Lib/mimetypes.py (cópia de trabalho)
@@ -173,7 +173,7 @@
extensions.append(ext)
return extensions
- def guess_extension(self, type, strict=True):
+ def guess_extension(self, type, strict=True, all_exts=False):
"""Guess the extension for a file based on its MIME type.
Return value is a string giving a filename extension,
@@ -188,8 +188,11 @@
"""
extensions = self.guess_all_extensions(type, strict)
if not extensions:
- return None
- return extensions[0]
+ extensions.append(None)
+ if all_exts:
+ return tuple(extensions)
+ else:
+ return extensions[0]
def read(self, filename, strict=True):
"""
@@ -304,7 +307,7 @@
init()
return _db.guess_all_extensions(type, strict)
-def guess_extension(type, strict=True):
+def guess_extension(type, strict=True, all_exts=False):
"""Guess the extension for a file based on its MIME type.
Return value is a string giving a filename extension, including the
@@ -318,7 +321,7 @@
"""
if _db is None:
init()
- return _db.guess_extension(type, strict)
+ return _db.guess_extension(type, strict, all_exts)
def add_type(type, ext, strict=True):
"""Add a mapping between a type and an extension.
« no previous file with comments | « no previous file | Lib/test/test_mimetypes.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7