Handles lookup of MIME types for files with support for custom MIME types.
More...
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.
◆ addMimeType()
None UM.MimeTypeDatabase.MimeTypeDatabase.addMimeType |
( |
|
cls, |
|
|
|
mime_type |
|
) |
| |
Add a custom MIME type that can be detected.
- Parameters
-
mime_type | MimeType The custom MIME type to add. |
◆ getMimeType()
MimeType UM.MimeTypeDatabase.MimeTypeDatabase.getMimeType |
( |
|
cls, |
|
|
|
name |
|
) |
| |
Get a MIME type by name.
This will return a MimeType
object corresponding to the specified name.
- Parameters
-
name | The name of the MIME type to return. |
- Returns
- A
MimeType
object corresponding to the specified name.
- Exceptions
-
MimeTypeNotFoundError | Raised when the specified MIME type cannot be found. |
◆ getMimeTypeForFile()
MimeType UM.MimeTypeDatabase.MimeTypeDatabase.getMimeTypeForFile |
( |
|
cls, |
|
|
|
file_name |
|
) |
| |
Get a MIME type for a specific file.
- Parameters
-
file_name | The name of the file to get the MIME type for. |
- Returns
- A MimeType object that contains the detected MIME type for the file.
- Exceptions
-
MimeTypeNotFoundError | Raised when no MIME type can be found for the specified file. |
The documentation for this class was generated from the following file: