views:

593

answers:

2

On my Centos server Python's mimetypes.guess_type("mobile.3gp") returns (None, None), instead of ('video/3gpp', None).

Where does Python get the list of mimetypes from, and is it possible to add a missing type to the list?

+5  A: 

On my system (Debian lenny) its in /usr/lib/python2.5/mimetypes.py in the list knownfiles you can supply your own files for the init() function.

unbeknown
Something I usually forget and that does not cause an error is passing just a simple string with a file path to init(). init() expects a list of file paths.
knabar
+2  A: 

The mimetypes module uses mime.types files as they are common on Linux/Unix systems. If you look in mimetypes.knownfiles you will find a list of files that Python tries to access to load the data. You can also specify your own file to add new types by adding it to that list.

tante