class RedirectEntry(BaseEntry):
Constructor: RedirectEntry(namespace, revision, redirect_index, url, ...)
An entry for a redirect.
| Class Method | from |
Read a content entry from a file. |
| Method | __init__ |
The default constructor. |
| Method | follow |
Follow this redirect and the next entry. |
| Method | get |
Calculate the size of this object when written to a file. |
| Method | redirect |
The position/offset of the entry in the URL entry list this entry redirects to. |
| Method | resolve |
Follow this redirect and any subsequent redirects until a non-redirect is reached. |
| Method | to |
Serialize this entry into a bytestring and return it. |
| Constant | FORMAT |
the format of this entry, excluding the mimetype |
| Constant | LENGTH |
Undocumented |
| Class Variable | LENGTH |
length of this entry, excluding mimetype and zero terminated parts |
| Property | redirect |
The position/offset of the entry in the URL entry list this entry redirects to. |
| Instance Variable | _redirect |
position/offset of the entry in the URL entry list this entry redirects to |
Inherited from BaseEntry:
| 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 | flush |
Write this entry to the archive if it is dirty. |
| Method | full |
The full URL, composed of namespace and url. |
| Method | is |
Whether this entry is an article or not. |
| Method | mimetype |
The mimetype as a string. Only available when bound. |
| Method | mimetype |
The index of the mimetype in the mimetypelist. |
| Method | namespace |
The namespace this entry is part of. |
| Method | parameters |
The extra parameters of this entry. |
| Method | remove |
Remove this entry from the archive it is bound to. |
| Method | revision |
The revision of the content of this entry. Unused, must be 0.. |
| Method | title |
The title of this entry. |
| Method | url |
The URL of this entry. |
| Constant | FORMAT |
the struct format to parse the mimetype |
| Constant | LENGTH |
length of the mimetype part of the struct |
| Constant | MIMETYPE |
mimetype index that identifies redirects |
| Instance Variable | mimetype |
The index of the mimetype in the mimetypelist. |
| Instance Variable | namespace |
The namespace this entry is part of. |
| Instance Variable | url |
The URL of this entry. |
| Property | full |
The full URL, composed of namespace and url. |
| Property | is |
Whether this entry is an article or not. |
| Property | is |
True if this entry is a redirect, False otherwise. |
| Property | mimetype |
The mimetype as string. Only available when bound. |
| Property | parameters |
The extra parameters of this entry. |
| Property | revision |
The revision of the content of this entry. Unused, must be 0. |
| Property | title |
The title of this entry. |
| Property | unmodified |
The full URL of this entry of the time this entry was last read or flushed. |
| Method | _get |
Return the size of the mimetype on disk in bytes. |
| Instance Variable | _force |
force-set the article state of this entry |
| Instance Variable | _mimetype |
index of mimetype in the mimetypelist. |
| Instance Variable | _namespace |
namespace this entry is part of |
| Instance Variable | _old |
full URL of entry as of last read/flush |
| Instance Variable | _parameters |
extra parameters. Unused, must be None. |
| Instance Variable | _revision |
the revision of the content of this entry. Unused, must be 0. |
| Instance Variable | _title |
title of this entry |
| Instance Variable | _url |
url of this entry |
Inherited from BindableMixIn (via BaseEntry):
| Method | bind |
Bind this object to a ZIM file. |
| Method | unbind |
Unbind this object. Can be called multiple times. |
| Property | bound |
Whether this object is bound to a ZIM file or not. |
| Property | zim |
The bound ZIM archive, if any is bound. Otherwise None. |
| Instance Variable | _zim |
the bound ZIM archive or None |
Inherited from ModifiableMixIn (via BaseEntry, BindableMixIn):
| Method | add |
Add another modifiable object as a child of this one. |
| 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. |
pyzim.entry.BaseEntry.from_fileRead a content entry from a file.
| Parameters | |
| f:file-like | file-like object to read from |
mimetype:int | index of mimetype. If specified, do not read it from file |
seek:int or None | if specified, seek this position of the file before reading |
| Returns | |
pyzim.entry.RedirectEntry | the entry read from the file |
pyzim.entry.BaseEntry.__init__The default constructor.
| Parameters | |
namespace:str | namespace this entry is part of |
revision:int | the revision of the content of this entry. Unused, must be 0. |
redirectint | position/offset of the entry this entry redirects to |
url:str | url of this entry |
title:str | title of this entry |
parameters:list | extra parameters. Unused, must be empty. |
Follow this redirect and the next entry.
This requires this entry to be bound. The next entry may be a redirect too.
| Returns | |
pyzim.entry.BaseEntry | the next entry |
| Raises | |
pyzim.exceptions.BindRequired | if not bound |
pyzim.entry.BaseEntry.get_disk_sizeCalculate 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 |
The position/offset of the entry in the URL entry list this entry redirects to.
| Parameters | |
value:int | value to set |
| Raises | |
TypeError | if value is not an integer |
pyzim.exceptions.NonMutable | if this entry is set to be inmutable. |
ValueError | if the value is invalid (e.g. negative) |
pyzim.entry.BaseEntry.resolveFollow this redirect and any subsequent redirects until a non-redirect is reached.
This requires this entry to be bound.
| Returns | |
pyzim.entry.BaseEntry | the first non-redirect entry |
| Raises | |
pyzim.exceptions.BindRequired | if not bound |
pyzim.entry.BaseEntry.to_bytesSerialize this entry into a bytestring and return it.
| Returns | |
bytes | a bytestring representing the content of this entry. |