Publication

An abstract EPUB publication.

The publication can be created by reading and parsing a compressed (ZIP/EPUB) file or an uncompressed directory, or built programmatically.

TODO The publication can be written to disk as a compressed (ZIP/EPUB) file or as an uncompressed directory.

class yael.publication.Publication(path=None, parsing_options=None)[source]

Build a publication or parse it from a compressed file or uncompressed directory.

If path is not None, build the publication by reading and parsing the file or directory path.

Parsing options can be specified by providing a non-empty list for the argument parsing_options. Recognized options are listed in yael.parsing.Parsing. If parsing_options is empty or None, full parsing will be performed.

Parameters:
  • path (str) – The path of the file or directory to be read.
  • parsing_options (list of yael.parsing.Parsing options) – parsing options
assets

The dictionary of assets in this publication. The keys are the internal paths of the assets, while the values are yael.asset.Asset objects.

Return type:dict of yael.asset.Asset
container

The META-INF/container.xml object for this Publication.

Return type:yael.container.Container
dcterms_modified

The last modification date/time of this Publication.

Return type:str
encryption

The META-INF/encryption.xml object for this Publication.

Return type:yael.encryption.Encryption
internal_path_cover_image

The path of cover image, relative to the Container root.

Return type:str
manifestation

The manifestation of this Publication.

Return type:yael.manifestation.Manifestation
metadata

The META-INF/metadata.xml object for this Publication.

Return type:yael.metadata.Metadata
parse()[source]

Parse the Publication.

parse_encryption()[source]

Parse META-INF/encryption.xml.

parse_multiple_renditions()[source]

Parse META-INF/metadata.xml and Multiple Renditions.

parse_rendition(rendition)[source]

Parse the given Rendition object.

path

The path of this Publication.

Return type:str
release_identifier

The Release Identifier of this Publication, that is:

  1. the concatenation of the Unique Identifier and the modification date in META-INF/metadata.xml (EPUB 3 publications with Multiple Renditions)
  2. the concatenation of the Unique Identifier and the modification date of the first Rendition (EPUB 3 publications without Multiple Renditions)
  3. the Unique Identifier of the first Rendition (EPUB 2 publications)
Return type:str
size

Compute and return the size of the publication.

For a yael.manifestation.Manifestation.COMPRESSED publication, it is the size of the EPUB (ZIP) Container, in bytes. For a yael.manifestation.Manifestation.UNCOMPRESSED publication, it is the sum of the sizes, in bytes, of the files in the uncompressed directory. In all other cases (i.e., for a yael.manifestation.Manifestation.MEMORY publication), returns -1.

Return type:int
unique_identifier

The Unique Identifier of this Publication.

The Unique Identifier is either:

  1. defined in the META-INF/metadata.xml (EPUB 3 publications with Multiple Renditions)
  2. defined in the Package Document of the first Rendition (other EPUB 2 and 3 publications)
Return type:str
version

The EPUB version of this Publication, computed as the version attribute of its default rendition.

Return type:str