Uranium
Application Framework
UM.MimeTypeDatabase.MimeTypeDatabase Class Reference

Handles lookup of MIME types for files with support for custom MIME types. More...

Public Member Functions

MimeType getMimeType (cls, str name)
 Get a MIME type by name. More...
 
MimeType getMimeTypeForFile (cls, str file_name)
 Get a MIME type for a specific file. More...
 
None addMimeType (cls, MimeType mime_type)
 Add a custom MIME type that can be detected. More...
 
None removeMimeType (cls, MimeType mime_type)
 

Static Public Attributes

 MimeTypeNotFoundError = MimeTypeNotFoundError
 

Detailed Description

Handles lookup of MIME types for files with support for custom MIME types.

This class wraps around QMimeDatabase and extends it with support for custom MIME types defined at runtime.

Note
Custom MIME types are currently only detected based on extension.

Member Function Documentation

◆ addMimeType()

None UM.MimeTypeDatabase.MimeTypeDatabase.addMimeType (   cls,
MimeType  mime_type 
)

Add a custom MIME type that can be detected.

Parameters
mime_typeThe custom MIME type to add.

◆ getMimeType()

MimeType UM.MimeTypeDatabase.MimeTypeDatabase.getMimeType (   cls,
str  name 
)

Get a MIME type by name.

This will return a MimeType object corresponding to the specified name.

Parameters
nameThe name of the MIME type to return.
Returns
A MimeType object corresponding to the specified name.
Exceptions
MimeTypeNotFoundErrorRaised when the specified MIME type cannot be found.

◆ getMimeTypeForFile()

MimeType UM.MimeTypeDatabase.MimeTypeDatabase.getMimeTypeForFile (   cls,
str  file_name 
)

Get a MIME type for a specific file.

Parameters
file_nameThe name of the file to get the MIME type for.
Returns
A MimeType object that contains the detected MIME type for the file.
Exceptions
MimeTypeNotFoundErrorRaised when no MIME type can be found for the specified file.

The documentation for this class was generated from the following file: