def loadMimeTypes(mimetype_locations=['/etc/mime.types']):
 import mimetypes
 contentTypes = mimetypes.types_map
 contentTypes.update({'.conf': 'text/plain', '.diff': 'text/plain', '.exe': 'application/x-executable', '.flac': 'audio/x-flac', '.java': 'text/plain', '.ogg': 'application/ogg', '.oz': 'text/x-oz', '.swf': 'application/x-shockwave-flash', '.tgz': 'application/x-gtar', '.wml': 'text/vnd.wap.wml', '.xul': 'application/vnd.mozilla.xul+xml', '.py': 'text/plain', '.patch': 'text/plain'})
 for location in mimetype_locations:
  if os.path.exists(location):
   more = mimetypes.read_mime_types(location)
   if (more is not None):
    contentTypes.update(more)
 return contentTypes

def loadMimeTypes ( mimetype_locations = [ '/etc/mime.types' ] ) : import mimetypes contentTypes = mimetypes . types_map contentTypes . update ( { '.conf' : 'text/plain' , '.diff' : 'text/plain' , '.exe' : 'application/x-executable' , '.flac' : 'audio/x-flac' , '.java' : 'text/plain' , '.ogg' : 'application/ogg' , '.oz' : 'text/x-oz' , '.swf' : 'application/x-shockwave-flash' , '.tgz' : 'application/x-gtar' , '.wml' : 'text/vnd.wap.wml' , '.xul' : 'application/vnd.mozilla.xul+xml' , '.py' : 'text/plain' , '.patch' : 'text/plain' } ) for location in mimetype_locations : if os . path . exists ( location ) : more = mimetypes . read_mime_types ( location ) if ( more is not None ) : contentTypes . update ( more ) return contentTypes
multiple file locations containing mime-types can be passed as a list .