Issue36489
Created on 2019-03-30 21:18 by Daniel Black, last changed 2022-04-11 14:59 by admin.
| Messages (4) | |||
|---|---|---|---|
| msg339221 - (view) | Author: Daniel Black (Daniel Black) | Date: 2019-03-30 21:18 | |
In https://bugs.python.org/issue36460 (which should be probably be disregarded until AMP is in RFC) I discovered that the types_map dictionary within the mimetypes module is a key: str to key: str (1:1) relationship. The reality is that many filename extensions commonly support multiple content-types and even sub types. A more useful structure might look like: (fne is "file name extension" aka foo) { '.fne': ['type1/subtype', 'type2/subtype'], '.htm': ['text/html', 'text/css', 'text/javascript'], '.html': ['text/html', 'text/css', 'text/javascript'] } However this seems to compete with the functionality of the types map so another consideration is content-types_map where the content-type is the key and the pair values are lists of valid filename extensions: { 'audio/x-aiff': ['.aifc', '.aiff', '.au'], 'text/html': ['.html', '.htm'] } |
|||
| msg339388 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2019-04-03 12:35 | |
> However this seems to compete with the functionality of the types map so another consideration is content-types_map where the content-type is the key and the pair values are lists of valid filename extensions: There is mimetypes.MimeTypes().types_map_inv > https://docs.python.org/3.8/library/mimetypes.html#mimetypes.MimeTypes.types_map_inv > Tuple containing two dictionaries, mapping MIME types to a list of filename extensions: the first dictionary is for the non-standards types and the second one is for the standard types. They are initialized by common_types and types_map. >>> mimetypes.MimeTypes().types_map_inv[1]['text/html'] ['.htm', '.html'] |
|||
| msg339417 - (view) | Author: Daniel Black (Daniel Black) | Date: 2019-04-03 20:15 | |
Thanks Karthikeyan. That is a bit cumbersome but gets it done. Any value seen in adding as proposed? |
|||
| msg339431 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2019-04-04 04:01 | |
The docs state the tuple contains two dictionaries depending on how common the type is. I guess you want a merged dict to be provided as an API? I will leave it to @r.david.murray on that. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:13 | admin | set | github: 80670 |
| 2019-04-04 04:01:00 | xtreak | set | messages: + msg339431 |
| 2019-04-03 20:15:36 | Daniel Black | set | messages: + msg339417 |
| 2019-04-03 12:35:10 | xtreak | set | nosy:
+ xtreak messages: + msg339388 |
| 2019-04-03 08:31:21 | SilentGhost | set | nosy:
+ r.david.murray type: enhancement |
| 2019-03-30 21:18:32 | Daniel Black | create | |
