This class represents a MIME type list.
The MIME type list contains an index->mimetype mapping. Each distinct mimetype used by entries is contained in the MIME type list. The entries themselves only contain the index of the MIME type in this list.
| Class Method | from |
Read the mime type list from a file. |
| Method | __init__ |
The default constructor. |
| Method | __len__ |
The length of this mimetype list. |
| Method | __str__ |
Return a string displaying the content of the mimetypelist. |
| Method | get |
Return the mimetype for the specified index. |
| Method | get |
Calculate the size of this object when written to a file. |
| Method | get |
Return the index for the specified mimetype. |
| Method | has |
Check if this mimetypelist has the specified mimetype. |
| Method | iter |
Iterate over all mimetypes in this list. |
| Method | register |
Register a mimetype in a thread-safe manner. |
| Method | to |
Dump this mime type list into a a bytestring. |
| Instance Variable | _lock |
thread safety lock |
| Instance Variable | _mimetypes |
(ordered) list of mimetypes in this object |
Inherited from ModifiableMixIn:
| Method | add |
Add another modifiable object as a child of this one. |
| Method | after |
This method should be called after this object has been read and/or flushed to disk. In other words, it should be called at least once whenever this object matches the state of the object on the disk. |
| Method | dirty |
Setter for ModifiableMixIn.dirty |
| Method | ensure |
If this object is non-mutable, raise an Exception. |
| Method | get |
Return the size of this object on disk as it has been read. |
| Method | get |
Return the size of this object when written to a file before any modifications has been made since the last read/flush. |
| Method | mark |
Convenience function to mark this object as dirty. |
| Method | remove |
Remove a submodifiable from this object. |
| Instance Variable | dirty |
True if this object or a sub-modifiable has been modified. |
| Instance Variable | mutable |
if not nonzero, prevent modifications of this object. |
| Instance Variable | _dirty |
a boolean flag that's nonzero if this object has been modified |
| Instance Variable | _old |
the size of this object on disk before any modifications since the last flush/read |
| Instance Variable | _submodifiables |
a list of child objects, whose dirty state will affect this objects dirty state. |
Read the mime type list from a file.
| Parameters | |
| f:file-like | file-like object to read from |
seek:int or None | if specified, seek this position |
| Returns | |
pyzim.mimetypelist.MimeTypeList | the mimetypelist read from the file |
Return a string displaying the content of the mimetypelist.
| Returns | |
str | a string describing the content of the mimetypelist |
Calculate the size of this object when written to a file.
NOTE: in this context, size refers to the direct size of the object. If this object contains references to other objects, their sizes will not be included. For example, a pyzim.entry.ContentEntry also links to a blob, but this function will only return the size of the entry itself, excluding the referenced blob.
| Returns | |
int | the size, in bytes |
Register a mimetype in a thread-safe manner.
Multiple registrations will be ignored, but should be avoided as the registration process in inefficient due to the lock.
| Parameters | |
mimetype:str or bytes | mimetype to register |
| Raises | |
pyzim.exceptions.NonMutable | if mimetype list is not mutable |