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

def getMimeType
 Get a MIME type by name. More...
 
def getMimeTypeForFile
 Get a MIME type for a specific file. More...
 
def addMimeType
 Add a custom MIME type that can be detected. More...
 

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()

def UM.MimeTypeDatabase.MimeTypeDatabase.addMimeType (   cls,
  mime_type 
)

Add a custom MIME type that can be detected.

Parameters
mime_typeThe custom MIME type to add.

◆ getMimeType()

def UM.MimeTypeDatabase.MimeTypeDatabase.getMimeType (   cls,
  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()

def UM.MimeTypeDatabase.MimeTypeDatabase.getMimeTypeForFile (   cls,
  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: