class documentation

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_entry Create an item from an entry.
Method __init__ The default constructor.
Method blob_source.setter The blob source for the content of the entry.
Method is_article.setter Whether the entry should be an article or not.
Method mimetype.setter The mimetype of the content.
Method namespace.setter The namespace the entry should be part of.
Method title.setter The title for this entry.
Method to_entry Instantiate a new entry from the information of this item.
Method url.setter The (non-full) url of the entry.
Property blob_source The blob source for the content of the entry.
Property is_article 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_source blob source for the content of the entry
Instance Variable _is_article 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
def from_entry(cls, entry):

Create an item from an entry.

Parameters
entry:pyzim.entry.ContentEntryentry to create item from
Returns
Itemthe created item
Raises
TypeErroron type error
def __init__(self, namespace, url, mimetype, blob_source, title=None, is_article=False):

The default constructor.

Parameters
namespace:strnamespace the entry should be part of (usually 'C')
url:str(non-full) url of the entry
mimetype:strmimetype of the content
blob_source:pyzim.blob.BaseBlobSourceblob source for the content of the entry
title:str or Nonetitle for this entry. If None, use the url instead
is_article:boolif nonzero, entry should be an article
Raises
TypeErroron invalid type
ValueErroron invalid values
def blob_source(self, value):

The blob source for the content of the entry.

Parameters
value:pyzim.blob.BaseBlobSourcevalue to set
Raises
TypeErroron invalid type
def is_article(self, value):

Whether the entry should be an article or not.

Parameters
value:boolvalue to set
Raises
TypeErroron invalid type
def mimetype(self, value):

The mimetype of the content.

Parameters
value:strvalue to set
Raises
TypeErroron invalid type
ValueErroron invalid value
def namespace(self, value):

The namespace the entry should be part of.

Parameters
value:strvalue to set
Raises
TypeErroron invalid type
ValueErroron invalid value
def title(self, value):

The title for this entry.

Parameters
value:str or Nonevalue to set
Raises
TypeErroron invalid type
ValueErroron invalid value
def to_entry(self, zim):

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.ZimZIM archive the entry should be part of
Returns
pyzim.entry.BaseEntryan entry with this items title, url, mimetype, ...
def url(self, value):

The (non-full) url of the entry.

Parameters
value:strvalue to set
Raises
TypeErroron invalid type
ValueErroron invalid value

The blob source for the content of the entry.

is_article: bool =

Whether the entry should be an article or not.

mimetype: str =

The mimetype of the content.

namespace: str =

The namespace the entry should be part of.

title: str =

The title for this entry.

url: str =

The (non-full) url of the entry.

blob source for the content of the entry

_is_article: bool =

if nonzero, entry should be an article

_mimetype: str =

mimetype of the content

_namespace: str =

namespace the entry should be part of

_title: str or None =

title for this entry. If None, use the url instead

_url: str =

(non-full) url of the entry