[issue1043134] Add preferred extensions for MIME types

2022-01-18 Thread Irit Katriel


Irit Katriel  added the comment:

PR14375 indeed adds a test for this as well (test_preferred_extension).

--
nosy: +iritkatriel
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2021-01-04 Thread Florian Bruhin


Florian Bruhin  added the comment:

I think this has been fixed in Python 3.7+ via 
https://github.com/python/cpython/pull/14375 - at least for a couple of types.

Comparing Python 3.6 with the current state, the following changed (which can 
be used as an "override" dict before calling mimetypes.guess_extension):

"application/manifest+json": ".webmanifest",  # not None
"application/octet-stream": ".bin",  # not .a
"application/postscript": ".ps",  # not .ai
"application/vnd.ms-excel": ".xls",  # not .xlb
"application/vnd.ms-powerpoint": ".ppt",  # not .pot
"application/wasm": ".wasm",  # not None
"application/x-hdf5": ".h5",  # not None
"application/xml": ".xsl",  # not .rdf
"audio/mpeg": ".mp3",  # not .mp2
"image/jpeg": ".jpg",  # not .jpe
"image/tiff": ".tiff",  # not .tif
"text/html": ".html",  # not .htm
"text/plain": ".txt",  # not .bat
"video/mpeg": ".mpeg",  # not .m1v

--
nosy: +The Compiler

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2019-05-01 Thread Josiah Carlson


Change by Josiah Carlson :


--
nosy:  -josiahcarlson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2018-07-08 Thread Sascha Silbe


Change by Sascha Silbe :


--
nosy: +sascha_silbe

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2016-09-20 Thread Tom Christie

Tom Christie added the comment:

Confirming that I've also bumped into this for Python 3.5.

A docs update would seem to be the lowest-cost option to start with.

Right now `mimetypes.guess_extension()` isn't terribly useful, and it'd be 
better to at least know that upfront.

--
nosy: +Tom.Christie

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-09-05 Thread Martin Panter

Martin Panter added the comment:

See also https://bugs.python.org/issue6626#msg91205, which mentions using a 
list of tuples instead of a dictionary, which sounds like it might help with 
this issue. Doing it that way you might be able avoid some duplication in the 
lists.

--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-06-19 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage: test needed - patch review
versions: +Python 3.5 -Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-05-15 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-05-13 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy:  -skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-04-04 Thread David Lindquist

David Lindquist added the comment:

Anyone interested in picking this up, or at least commenting on the approach I 
suggested in the patch? Seems like an easy fix for a long-standing bug.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-03-27 Thread Wichert Akkerman

Wichert Akkerman added the comment:

Here is a related question on SO: 
http://stackoverflow.com/questions/352837/how-to-add-file-extensions-based-on-file-type-on-linux-unix

--
nosy: +wichert

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-03-01 Thread David Lindquist

David Lindquist added the comment:

I don't think it is unreasonable to return a well-known extension for certain 
mime types, text/plain being the most obvious (and most in need of repair; 
.ksh??).

I've attached a patch based on the previous discussion.

--
keywords: +patch
nosy: +david.lindquist
Added file: http://bugs.python.org/file34262/mimetypes.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2014-02-03 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
nosy:  -BreamoreBoy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2012-10-11 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti
versions: +Python 3.4 -Python 2.7, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2012-10-10 Thread Evan Jones

Changes by Evan Jones e...@evanjones.ca:


--
nosy: +evanj

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2011-09-07 Thread Leo Shklovskii

Leo Shklovskii l...@thermopylae.net added the comment:

I'm running into a similar issue with this function. My bug is that 
get_type('foo.png') returns image/x-png. This occurs on windows because there 
are mappings to both image/png and image/x-png in the registry (as there should 
be, since that key is actually a reverse mapping) and the code simply picks the 
first key that it enumerates over. This issue strikes in both directions.

Chris and others bring up a valid issue: how to decide what the winning result 
is?

I think the answer is pretty clear - you use the common_types mapping already 
in the file and expand it as appropriate. If the mimetype can't be found, only 
then do you go to the windows registry. The behavior on Linux is even stranger 
to me (now we'll dig through an arbitrary list of files that might contain MIME 
info or may have completely irrelevant data) but it's a pragmatic solution.

If someone needs to customize what guess_type returns, they can simply wrap the 
guess_type function in their own code or monkey patch if they don't have access 
to the source they're running. Changing such a mime type is a really advanced 
and unusual operation. If that's unacceptable, the code can provide a hook for 
an 'apache MIME config' file on windows in a standard place (either pythonpath, 
or %system% or wherever) that it will check before going to common_types or to 
the registry.

Making this change doesn't require changing the API at all, just the 
implementation changes.

--
nosy: +leos
versions: +Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2011-08-20 Thread Sandro Tosi

Changes by Sandro Tosi sandro.t...@gmail.com:


--
nosy: +sandro.tosi

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1043134] Add preferred extensions for MIME types

2011-07-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

The proposed patch does not solve the issue.  In the current API, there is no 
way to do it, so this bug requires a new feature.  I think it would involve a 
new dict, like preferred_extensions, which would be seeded with default values, 
like .jpg for image/jpeg and .txt for text/plain, and a few functions/methods 
to query the dict or add items.

--
keywords:  -easy, patch
title: mimetypes.guess_extension('text/plain') == '.ksh' ??? - Add preferred 
extensions for MIME types

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1043134
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com