SimpleEPUB

A simplified interface for reading, editing, and writing EPUB 2 and EPUB 3 eBooks with just one Rendition.

It also exposes some vanity functions.

If you need Multiple Renditions or more control, you should use yael.publication.Publication instead.

class yael.simpleepub.SimpleEPUB(path=None, parsing_options=None)[source]

Build a simple EPUB programmatically or parse it from path.

Parameters:
  • path (str) – a path to an EPUB (compressed) file or to a directory (uncompressed)
  • parsing_options (list of yael.parsing.Parsing values) – a list of parsing options
asset_contents(internal_path)[source]

Return the contents of the asset with the given internal path, relative to the container root.

Parameters:internal_path (str) – the internal path of the desired asset
Return type:bytes
author

The value of the (first) dc:author metadatum.

Return type:str
cover_image

The contents of the cover image.

Return type:bytes
date

The value of the (first) dc:date metadatum.

Return type:str
dcterms_modified

The value of the dcterms:modified date. (EPUB 3)

Return type:str
description

The value of the (first) dc:description metadatum.

Return type:str
get_dc_metadatum(tag, only_first=True, as_string=True)[source]

Get the value(s) of <dc:...> metadatum/metadata.

Parameters:
  • tag (str) – the name of the desired metadatum Use a yael.dc.DC E_NS_ value.
  • only_first (bool) – only return the first metadatum
  • as_string (bool) – return only the value of the metadatum, as a string
Return type:

(list of) str or yael.opfdc.OPFDC

identifier

The value of the (first) dc:identifier metadatum.

Return type:str
internal_path_cover_image

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

Return type:str
landmarks

The landmarks (EPUB 3 only).

Return type:yael.navelement.NavElement
language

The value of the (first) dc:language metadatum.

Return type:str
manifestation

The manifestation of this Publication.

Return type:yael.manifestation.Manifestation
publisher

The value of the (first) dc:publisher metadatum.

Return type:str
release_identifier

The value of the release identifier.

Return type:str
resolved_landmarks

The landmarks (EPUB 3 only), where the src values have been resolved into the corresponding internal paths (relative to the container root).

Return type:yael.navelement.NavElement
resolved_spine

The spine, as a (ordered) list of internal paths to the assets referenced in the actual OPF <spine>.

Return type:list of str
resolved_spine_linear

The spine, as a (ordered) list of internal paths to the assets referenced in the actual OPF <spine>, with attribute linear=”yes” or omitted.

Return type:list of str
resolved_toc

The TOC, where the src values have been resolved into the corresponding internal paths (relative to the container root).

Return type:yael.navelement.NavElement or yael.ncxtoc.NCXToc
rights

The value of the (first) dc:rights metadatum.

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
source

The value of the (first) dc:source metadatum.

Return type:str
spine_index_by_internal_path(internal_path)[source]

Return the index in the spine of the file located at the given internal path (relative to the Container root).

Parameters:internal_path (str) – the internal path of the desired item
Returns:the index in the spine, or -1 if not found
Return type:int
spine_linear_index_by_internal_path(internal_path)[source]

Return the index in the linear spine of the file located at the given internal path (relative to the Container root).

Parameters:internal_path (str) – the internal path of the desired item
Returns:the index in the spine, or -1 if not found
Return type:int
subjects

The list of values of dc:subject metadata.

Return type:list of str
title

The value of the (first) dc:title metadatum.

Return type:str
toc

The TOC.

Return type:yael.navelement.NavElement or yael.ncxtoc.NCXToc
type

The value of the (first) dc:type metadatum.

Return type:str
unique_identifier

The value of the unique identifier.

Return type:str
version

The value of the EPUB version (it should be “2.0” or “3.0”).

Return type:str