An item is a helper for simplifying the addition of new content to a ZIM.
When adding new content to a ZIM, you would normally have to add the blob to a cluster, write the cluster, then create an entry and set the pointers correctly before writing it. This is quite useful, but also unneccessary complicated, which is where this class comes in.
An Item contains all the metadata needed create and insert an entry and provides method that allow the pyzim.compressionstrategy.BaseCompressionStrategy to automatically at it to a cluster.
| Class Method | from |
Create an item from an entry. |
| Method | __init__ |
The default constructor. |
| Method | blob |
The blob source for the content of the entry. |
| Method | is |
Whether the entry should be an article or not. |
| Method | mimetype |
The mimetype of the content. |
| Method | namespace |
The namespace the entry should be part of. |
| Method | title |
The title for this entry. |
| Method | to |
Instantiate a new entry from the information of this item. |
| Method | url |
The (non-full) url of the entry. |
| Property | blob |
The blob source for the content of the entry. |
| Property | is |
Whether the entry should be an article or not. |
| Property | mimetype |
The mimetype of the content. |
| Property | namespace |
The namespace the entry should be part of. |
| Property | title |
The title for this entry. |
| Property | url |
The (non-full) url of the entry. |
| Instance Variable | _blob |
blob source for the content of the entry |
| Instance Variable | _is |
if nonzero, entry should be an article |
| Instance Variable | _mimetype |
mimetype of the content |
| Instance Variable | _namespace |
namespace the entry should be part of |
| Instance Variable | _title |
title for this entry. If None, use the url instead |
| Instance Variable | _url |
(non-full) url of the entry |
Create an item from an entry.
| Parameters | |
entry:pyzim.entry.ContentEntry | entry to create item from |
| Returns | |
Item | the created item |
| Raises | |
TypeError | on type error |
The default constructor.
| Parameters | |
namespace:str | namespace the entry should be part of (usually 'C') |
url:str | (non-full) url of the entry |
mimetype:str | mimetype of the content |
blobpyzim.blob.BaseBlobSource | blob source for the content of the entry |
title:str or None | title for this entry. If None, use the url instead |
isbool | if nonzero, entry should be an article |
| Raises | |
TypeError | on invalid type |
ValueError | on invalid values |
The blob source for the content of the entry.
| Parameters | |
value:pyzim.blob.BaseBlobSource | value to set |
| Raises | |
TypeError | on invalid type |
The mimetype of the content.
| Parameters | |
value:str | value to set |
| Raises | |
TypeError | on invalid type |
ValueError | on invalid value |
The namespace the entry should be part of.
| Parameters | |
value:str | value to set |
| Raises | |
TypeError | on invalid type |
ValueError | on invalid value |
The title for this entry.
| Parameters | |
value:str or None | value to set |
| Raises | |
TypeError | on invalid type |
ValueError | on invalid value |
Instantiate a new entry from the information of this item.
Cluster and blob numbers do not have to be set. The resulting entry will be bound.
| Parameters | |
zim:pyzim.archive.Zim | ZIM archive the entry should be part of |
| Returns | |
pyzim.entry.BaseEntry | an entry with this items title, url, mimetype, ... |
The (non-full) url of the entry.
| Parameters | |
value:str | value to set |
| Raises | |
TypeError | on invalid type |
ValueError | on invalid value |