file.utils
Attributes
Functions
|
Gets the content type from a file obj. Depot has this as well, but it |
|
|
|
Queries PIL for all locally supported mime types. |
|
|
|
Gets the extension for the given content type. Note that this is |
|
|
|
|
|
The word-count of the given text. Goes through the string exactly |
|
|
|
Module Contents
- file.utils.content_type_from_fileobj(fileobj: SupportsRead[bytes]) str [source]
Gets the content type from a file obj. Depot has this as well, but it doesn’t use python-magic. We use python-magic to be slower, but more accurate.
- file.utils.as_fileintent(content: bytes | IO[bytes], filename: str | None) depot.io.utils.FileIntent [source]
- file.utils.get_supported_image_mime_types() set[str] [source]
Queries PIL for all locally supported mime types.
Adapted from: https://github.com/python-pillow/Pillow/issues/1182#issuecomment-90572583
- file.utils.extension_for_content_type(content_type: str, filename: str | None = None) str [source]
Gets the extension for the given content type. Note that this is meant for display only. A file claiming to be a PDF might not be one, but this function would not let you know that.
- file.utils.digest(fileobj: SupportsRead[bytes], type: str = 'sha256', chunksize: int = 4096) str [source]