This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mimetypes: all extensions for a type
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: doerwalter Nosy List: barry, doerwalter, loewis
Priority: normal Keywords: patch

Created on 2002-05-09 17:31 by doerwalter, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff.txt doerwalter, 2002-05-09 17:32
diff2.txt doerwalter, 2002-08-15 17:40
diff3.txt doerwalter, 2002-08-19 12:57
Messages (12)
msg39961 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-05-09 17:31
This patch adds a function guess_all_extensions to 
mimetypes.py. This function returns all known 
extensions for a given type, not just the first one 
found in the types_map dictionary. guess_extension is 
still present and returns the first from the list.
msg39962 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-28 10:30
Logged In: YES 
user_id=21627

What is the role of add_type in this patch?
msg39963 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-07-29 08:23
Logged In: YES 
user_id=89016

The patch adds an inverted mapping (i.e. mapping from type
to a list of extensions). add_type simplifies adding a
type<->ext mapping to both dictionaries. If this method
should not be exposed we could make the name private.
(_add_type)
msg39964 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-29 08:44
Logged In: YES 
user_id=21627

I can't see the point of making it private, since it is not
used inside the module. If you plan to use it, that usage
certainly is outside of the module, so the method would be
public.

If it is public, it needs to be exposed on the module level,
and it needs to be documented.
msg39965 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-07-30 11:00
Logged In: YES 
user_id=89016

It *is* used in two spots: The constructor and the readfp 
method. But exposing it at the module level could make 
sense, because it is the atomic method of adding mime type 
information. So should it change the patch to expose it at the 
module level and change the LaTeX documentation 
accordingly?
msg39966 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-30 12:34
Logged In: YES 
user_id=21627

I'm in favour of exposing it on the module level. If you are
uncertain, you might want to ask on python-dev.
msg39967 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-07-31 11:24
Logged In: YES 
user_id=89016

OK, I'll change the patch and post the question to python-dev 
next week (I'm on vacation right now).
msg39968 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-08-15 17:40
Logged In: YES 
user_id=89016

diff2.txt adds the global version of add_type and the
documentation in Doc/lib/libmimetypes.tex.
msg39969 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2002-08-15 18:18
Logged In: YES 
user_id=12800

If add_type() is going to be public, shouldn't it have a
"strict" flag to decide whether to add it to the standard
types dict or the common types dict?
msg39970 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-08-19 12:57
Logged In: YES 
user_id=89016

diff3.txt adds a strict=True to add_type and to all methods
that call add_type (i.e. read() and readfp()). types_map and
common_types are combined into a dict tuple (in the class,
on the module level they are still two dicts, to be
backwards compatible.)

What about adding a guess_all_types(), that returns a list
of all registered mimetypes for an exception? This way we
would be able to handle duplicates.
msg39971 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-09-06 09:45
Logged In: YES 
user_id=21627

Looks good, please apply it. Don't forget to edit Misc/NEWS.
msg39972 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2002-09-06 16:19
Logged In: YES 
user_id=89016

Checked in as:
Doc/lib/libmimetypes.tex 1.11
Lib/mimetypes.py 1.23
Misc/NEWS 1.481
History
Date User Action Args
2022-04-10 16:05:18adminsetgithub: 36579
2002-05-09 17:31:39doerwaltercreate