wx.MimeTypesManager

Inheritance diagram for wx.MimeTypesManager:



Description

This class allows the application to retrieve the information about all known MIME types from a system-specific location and the filename extensions to the MIME types and vice versa. After initialization the functions GetFileTypeFromMimeType and GetFileTypeFromExtension may be called: they will return a wx.FileType object which may be further queried for file description, icon and other attributes.

Note

Windows: MIME type information is stored in the registry and no additional initialization is needed.

Note

Unix: MIME type information is stored in the files mailcap and mime.types (system-wide) and .mailcap and .mime.types in the current user’s home directory: all of these files are searched for and loaded if found by default. However, additional functions ReadMailcap and ReadMimeTypes are provided to load additional files.

If GNOME or KDE desktop environment is installed, then wx.MimeTypesManager gathers MIME information from respective files (e.g. .kdelnk files under KDE).

Note

Currently, wx.MimeTypesManager is limited to reading MIME type information but it will support modifying it as well in future versions.

Class API

Methods

__init__()

Constructor puts the object in the “working” state, no additional initialization are needed – but ReadXXX may be used to load additional mailcap/mime.types files.

Returns:

wx.MimeTypesManager

Note

You normally do not need to call this method.


AddFallback(ft)

This function may be used to provide hard-wired fallbacks for the MIME types and extensions that might not be present in the system MIME database.

Parameters:

  • ft (wx.FileTypeInfo)

Associate(ftInfo)

Parameters:

  • ftInfo (wx.FileTypeInfo)

Returns:

wx.FileType


ClearData()
No docstrings available for this method.

EnumAllFileTypes()
No docstrings available for this method.

GetFileTypeFromExtension(extension)

Gather information about the files with given extension and return the corresponding wx.FileType object or None if the extension is unknown.

The extension parameter may have, or not, the leading dot, if it has it, it is stripped automatically. It must not however be empty.

Parameters:

  • extension (string)

Returns:

wx.FileType


GetFileTypeFromMimeType(mimeType)

Gather information about the files with given MIME type and return the corresponding wx.FileType object or None if the MIME type is unknown.

Parameters:

  • mimeType (string)

Returns:

wx.FileType


Initialize(mailcapStyle=wx.MAILCAP_ALL, extraDir="")

Parameters:

  • mailcapStyle (int)
  • extraDir (string)

IsOfType(mimeType, widlcard)

This function returns True if either the given mimeType is exactly the same as wildcard or if it has the same category and the subtype of wildcard is ‘*’.

The comparison don by this function is case insensitive so it is not necessary to convert the strings to the same case before calling it.

Parameters:

  • mimeType (string)
  • wildcard (string)

Returns:

bool

Note

Note that the ‘*’ wildcard is not allowed in mimeType parameter itself.


ReadMailcap(filename, fallback=False)

Load additional file containing information about MIME types and associated information in mailcap format. See metamail(1) and mailcap(5) for more information.

fallback parameter may be used to load additional mailcap files without overriding the settings found in the standard files: normally, entries from files loaded with ReadMailcap will override the entries from files loaded previously (and the standard ones are loaded in the very beginning), but this will not happen if this parameter is set to True (default is False).

The return value is True if there were no errors in the file or False otherwise.

Parameters:

  • filename (string)
  • fallback (bool)

Returns:

bool


ReadMimeTypes(filename)

Load additional file containing information about MIME types and associated information in mime.types file format. See metamail(1) and mailcap(5) for more information.

The return value is True if there were no errors in the file or False otherwise.

Parameters:

  • filename (string)

Returns:

bool


Unassociate(ft)

Parameters:


Returns:

bool