epublib.resources.manager module¶
- class AddResourceOptions¶
Bases:
TypedDict
- class GenericResourceManager(resources: ~collections.abc.MutableSequence, container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function GenericResourceManager.<lambda>>)¶
Bases:
MutableSequence,ABC,Generic- ri_to_filename(
- identifier: ResourceIdentifier,
Convert various resource identifier types to its corresponding filename, or None if not found.
- Parameters:
identifier – The resource identifier – filename (str or Path),
id (an)
- Returns:
The corresponding filename as a string, or None if resource is not found.
- ri_to_id(
- identifier: ResourceIdentifier,
Convert various resource identifier types to its corresponding EPUBId.
- Parameters:
identifier – The resource identifier – filename (str or Path), an id (EPUBId), a manifest item or a spine item – to convert.
- Returns:
The corresponding EPUBId as a string, or None if resource is not found.
- filter( ) Generator[T]¶
- filter(query: ResourceQuery[R]) Generator[R]
- filter(
- query: type[T] | None = None,
Filter resources in this EPUB by media type, category or class.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... xhtml_files = list(book.resources.filter(MediaType.IMAGE_PNG)) ... filenames = [res.filename for res in xhtml_files] >>> filenames ['Images/image.png', 'Images/image2.png']
- Parameters:
query – The query to filter by. If None, all resources are returned. If a MediaType is provided, all PublicationResources with that media type are returned. If a Category is provided, all PublicationResources in that category are returned. If a class (subclass of Resource) is provided, all resources of that class are returned.
- Yields:
Resources matching the query.
- get(
- identifier: ResourceIdentifier,
- query: ResourceQuery | None = None,
Get a resource by an identifier, optionally filtering by a query.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... resource = book.resources.get("Text/chapter1.xhtml") ... filename = resource.filename if resource else None >>> filename 'Text/chapter1.xhtml'
- Parameters:
identifier – The resource identifier – filename (str or Path), an id (EPUBId), a manifest item or a spine item – to get.
query – The query to filter by. If None, all resources are considered. If a MediaType is provided, only PublicationResources with that media type are considered. If a Category is provided, only PublicationResources in that category are considered. If a class (subclass of Resource) is provided, only resources of that class are considered.
- Returns:
The resource matching the identifier and query, or None if not found.
- count(
- value,
- index(
- value[,
- start[,
- stop,]]
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- add_to_manifest(
- resource: R,
- media_type: MediaType | str | None = None,
- identifier: EPUBId | str | None = None,
- fallback: str | None = None,
- media_overlay: str | None = None,
- is_cover: bool = False,
- is_nav: bool = False,
- properties: list[str] | None = None,
- detect_properties: bool = True,
- exists_ok: bool = False,
Add a resource to the manifest, if not already present. The resource may be promoted to a PublicationResource if needed, so the resource is returned as well.
- Parameters:
resource – The resource to add to the manifest.
media_type – The media type of the resource. If None, it will be inferred from the resource’s filename.
identifier – The identifier to use for the manifest item. If None, an identifier will be generated.
fallback – The id of a fallback item, if any.
media_overlay – The id of a media overlay item, if any.
is_cover – Whether this resource is the cover image.
is_nav – Whether this resource is the navigation document.
properties – Additional properties to add to the manifest item.
detect_properties – Whether to automatically detect properties based on the resource’s media type and role (e.g. nav, cover).
exists_ok – If True, do not raise an error if the resource is already in the manifest.
- Returns:
A tuple (resource, manifest_item) of the (possibly promoted) resource and the manifest item.
- Raises:
If the resource is already in the manifest and exists_ok is False. - If the resource is not a PublicationResource and media_type is not provided, and it can’t be inferred from the resource’s filename. - If is_nav is True but the media type is not XHTML or SVG.
- add(
- resource: T,
- is_cover: bool = False,
- position: int | None = None,
- after: Resource | ResourceIdentifier | None = None,
- before: Resource | ResourceIdentifier | None = None,
- add_to_manifest: bool | None = None,
- identifier: str | EPUBId | None = None,
- add_to_spine: bool | None = None,
- spine_position: int | None = None,
- linear: bool | None = None,
- add_to_toc: bool | None = None,
- toc_position: int | None = None,
- add_to_ncx: bool | None = None,
- ncx_position: int | None = None,
Add a resource to this EPUB.
Typicial usage is from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> resource = create_resource(b"<svg></svg>", "image.svg") >>> with EPUB(sample) as book: ... book.resources.add(resource, is_cover=True, position=3) ... filename = book.resources[3].filename >>> filename 'image.svg'
- Parameters:
resource – The resource to add.
is_cover – Whether this resource is the cover image.
position – The position to insert the resource at. If None, the resource is appended to the end.
after – A resource or identifier of a resource to insert after. Ignored if position is provided.
before – A resource or identifier of a resource to insert before. Ignored if position or after is provided.
add_to_manifest – Whether to add the resource to the manifest. If None, it will be added if it isn’t in the META-INF folder.
identifier – The identifier to use for the manifest item. If None, an identifier will be generated.
add_to_spine – Whether to add the resource to the spine. If None, it will be added if it is a ContentDocument.
spine_position – The position in the spine to insert the resource. If None, it will be appended to the end of the spine.
linear – Whether the spine item should be linear. If None, it will be linear.
add_to_toc – Whether to add the resource to the navigation document’s table of contents. If None, it will be added if it is in the spine.
toc_position – The position in the navigation document’s table of content. If None, it will be appended to the end.
add_to_ncx – Whether to add the resource to the NCX file’s. If None, it will be added if there is an NCX file and if add_to_toc is True.
ncx_position – The position in the NCX file’s table of content. If None, it will be the same as toc_position.
- Raises:
If add_to_spine is True but add_to_manifest is False. - If add_to_toc is True but add_to_manifest is False. - If add_to_ncx is True but there is no NCX file. - If the resource is already in the EPUB.
- insert(
- position: int,
- resource: T,
- **kwargs: Unpack[AddResourceOptions],
Insert a resource at a given position in this EPUB.
- Parameters:
position – The position to insert the resource at.
resource – The resource to add.
**kwargs – Additional options to pass to add().
- Raises:
If add_to_spine is True but add_to_manifest is False. - If add_to_toc is True but add_to_manifest is False. - If add_to_ncx is True but there is no NCX file. - If the resource is already in the EPUB.
- append(
- resource: T,
- **kwargs: Unpack[AddResourceOptions],
Insert a resource at the end of an EPUB.
- Parameters:
resource – The resource to add.
**kwargs – Additional options to pass to add().
- Raises:
If add_to_spine is True but add_to_manifest is False. - If add_to_toc is True but add_to_manifest is False. - If add_to_ncx is True but there is no NCX file. - If the resource is already in the EPUB.
- remove(
- resource: ResourceIdentifier | T,
- remove_css_js_links: bool | None = None,
Remove a resource from this EPUB.
- Parameters:
resource – The resource or identifier of the resource to remove.
remove_css_js_links – Whether to remove links to this resource from content documents if it is a CSS or JavaScript file. If None, links will be removed if the resource is a CSS or JavaScript file. If False, links will not be removed.
- Raises:
If the resource is not in this EPUB. - If trying to remove the container file, package document or navigation document. - If remove_css_js_links is True but the resource is not a CSS or JavaScript file.
- rename(
- resource: ResourceIdentifier | T,
- new_filename: str | Path,
- update_references: bool = True,
- reference_attrs: list[str] | None = None,
Rename the resource, optionally updating references to it.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... _, tag = next(book.resources.tags_referencing("Text/chapter1.xhtml")) ... book.resources.rename("Text/chapter1.xhtml", "Text/chapter100.xhtml") >>> tag <a href="chapter100.xhtml"...
- Parameters:
resource – The resource or identifier of the resource to rename.
new_filename – The new filename for the resource.
update_references – Whether to update references to this resource in other resources. Defaults to True.
reference_attrs – The attributes to update references in. If None, the default attributes will be used: (‘href’, ‘src’, ‘full-path’, ‘xlink:href’).
- Raises:
If the resource is not in this EPUB. - If trying to rename the container file.
- resolve_href(
- href: str,
- with_tag: Literal[False],
- relative_to: Resource | ResourceIdentifier | None,
- query: ResourceQuery[R],
- resolve_href(
- href: str,
- with_tag: Literal[False],
- relative_to: T | ResourceIdentifier | None = None,
- query: None = None,
- resolve_href(
- href: str,
- with_tag: Literal[True] = True,
- relative_to: Resource | ResourceIdentifier | None = None,
- query: None = None,
- resolve_href(
- href: str,
- with_tag: Literal[True] = True,
- relative_to: Resource | ResourceIdentifier | None = None,
- query: ResourceQuery[R] | None = None,
- resolve_href(
- href: str,
- with_tag: bool = True,
- relative_to: Resource | ResourceIdentifier | None = None,
- query: ResourceQuery[R] | None = None,
Resolve an href (possibly with a fragment identifier) to a resource. Optionally return the tag of the matched fragment within that resource.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... resource, tag = book.resources.resolve_href( ... "chapter1.xhtml#heading2", ... relative_to="Text/nav.xhtml" ... ) >>> tag <h2 id="heading2">Heading 2</h2> >>> resource.filename 'Text/chapter1.xhtml'
- Parameters:
href – The href to resolve. May include a fragment identifier.
with_tag – Whether to return the tag of the matched fragment within the resource. Defaults to True.
relative_to – The resource or identifier of the resource containing the href, if the href is relative. If None, the href is considered absolute. Defaults to None.
query – The query parameter to pass to the get method.
- set_cover_image(
- resource: ResourceIdentifier | Resource,
Set the cover image of this EPUB. The resource must be an image and will be added to the manifest if not already present.
- Parameters:
resource – The resource or identifier of the resource to set as the cover image.
- Raises:
If the resource is not in this EPUB. - If the resource is not an image.
- tags_referencing(
- filename: str | Path,
- reference_attrs: Sequence[str] | None = None,
- ignore_fragment: bool = False,
Find all tags and their respective resources in content documents that reference the given filename.
- Parameters:
filename – The filename to search for, possibily with a fragment.
reference_attrs – The attributes to search for references in. If None, the default attributes will be used: (‘href’, ‘src’, ‘full-path’, ‘xlink:href’).
ignore_fragment – Whether to ignore fragment identifiers when searching for references. Defaults to False.
- Yields:
Tuples of (resource, tag) where tag it the tag that references filename and resource is the content document containing that tag.
- class ResourceManager(resources: ~collections.abc.MutableSequence, container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function GenericResourceManager.<lambda>>)¶
Bases:
GenericResourceManager[Resource]The resource manager for an EPUB. Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... num_resources = len(book.resources) ... first_resource = book.resources[0] >>> num_resources 8 >>> first_resource.filename 'mimetype'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- filter(
- query: Literal[MediaType.XHTML, MediaType.IMAGE_SVG],
- filter(
- query: Literal[MediaType.NCX],
- filter( ) Generator[PublicationResource]
- filter(query: ResourceQuery[R]) Generator[R]
- filter(
- query: ResourceQuery[Resource] | None = None,
Filter resources in this EPUB by media type, category or class.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... xhtml_files = list(book.resources.filter(MediaType.IMAGE_PNG)) ... filenames = [res.filename for res in xhtml_files] >>> filenames ['Images/image.png', 'Images/image2.png']
- Parameters:
query – The query to filter by. If None, all resources are returned. If a MediaType is provided, all PublicationResources with that media type are returned. If a Category is provided, all PublicationResources in that category are returned. If a class (subclass of Resource) is provided, all resources of that class are returned.
- Yields:
Resources matching the query.
- get(
- identifier: EPUBId | ManifestItem,
- query: type[R],
- get(
- identifier: EPUBId | ManifestItem | SpineItemRef,
- query: ResourceQuery[PublicationResource] = PublicationResource,
- get(
- identifier: str | Path,
- query: type[R],
- get(
- identifier: str | Path,
- query: ResourceQuery[Resource] = Resource,
Get a resource by an identifier, optionally filtering by a query.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... resource = book.resources.get("Text/chapter1.xhtml") ... filename = resource.filename if resource else None >>> filename 'Text/chapter1.xhtml'
- Parameters:
identifier – The resource identifier – filename (str or Path), an id (EPUBId), a manifest item or a spine item – to get.
query – The query to filter by. If None, all resources are considered. If a MediaType is provided, only PublicationResources with that media type are considered. If a Category is provided, only PublicationResources in that category are considered. If a class (subclass of Resource) is provided, only resources of that class are considered.
- Returns:
The resource matching the identifier and query, or None if not found.
- resolve_href(
- href: str,
- with_tag: Literal[False],
- relative_to: Resource | ResourceIdentifier | None,
- query: ResourceQuery[R],
- resolve_href(
- href: str,
- with_tag: Literal[False],
- relative_to: Resource | ResourceIdentifier | None = None,
- query: None = None,
- resolve_href(
- href: str,
- with_tag: Literal[True] = True,
- relative_to: Resource | ResourceIdentifier | None = None,
- query: None = None,
- resolve_href(
- href: str,
- with_tag: Literal[True] = True,
- relative_to: Resource | ResourceIdentifier | None = None,
- query: ResourceQuery[R] | None = None,
Resolve an href (possibly with a fragment identifier) to a resource. Optionally return the tag of the matched fragment within that resource.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... resource, tag = book.resources.resolve_href( ... "chapter1.xhtml#heading2", ... relative_to="Text/nav.xhtml" ... ) >>> tag <h2 id="heading2">Heading 2</h2> >>> resource.filename 'Text/chapter1.xhtml'
- Parameters:
href – The href to resolve. May include a fragment identifier.
with_tag – Whether to return the tag of the matched fragment within the resource. Defaults to True.
relative_to – The resource or identifier of the resource containing the href, if the href is relative. If None, the href is considered absolute. Defaults to None.
query – The query parameter to pass to the get method.
- class WindowedResourceManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
GenericResourceManager,ABC,Generic
- class PublicationResourceManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
WindowedResourceManager[PublicationResource]The resource manager for publication resources in an EPUB. An implementation of the resource manager windowed for publication resources. Publication resources are all resources that contribute to the reading of the publication (and are thus listed in the manifest).
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... num_resources = len(book.publication_resources) ... first_resource = book.publication_resources[0] >>> num_resources 5 >>> first_resource.filename 'Text/nav.xhtml'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- base_class¶
alias of
PublicationResource
- class ImagesManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
PublicationResourceManagerThe resource manager for images in an EPUB. An implementation of the resource manager windowed for images.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> with EPUB(sample) as book: ... num_resources = len(book.images) ... first_resource = book.images[0] >>> num_resources 2 >>> first_resource.filename 'Images/image.png'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- class ScriptsManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
PublicationResourceManagerThe resource manager for scripts in an EPUB. An implementation of the resource manager windowed for scritps.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> with EPUB(sample) as book: ... resource = create_resource(b"console.log('Hello, world!');", "Misc/script.js") ... book.scripts.add(resource) ... num_resources = len(book.scripts) ... first_resource = book.scripts[0] >>> num_resources 1 >>> first_resource.filename 'Misc/script.js'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- class StylesManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
PublicationResourceManagerThe resource manager for stylesheets in an EPUB. An implementation of the resource manager windowed for stylesheets.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> with EPUB(sample) as book: ... resource = create_resource(b"p { color: orange }", "Styles/design.css") ... book.styles.insert(0, resource) ... num_resources = len(book.styles) ... first_resource = book.styles[0] >>> num_resources 2 >>> first_resource.filename 'Styles/design.css'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- class FontsManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
PublicationResourceManagerThe resource manager for fonts in an EPUB. An implementation of the resource manager windowed for fonts.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> with EPUB(sample) as book: ... resource = create_resource(b"", "Fonts/font.ttf") ... book.fonts.insert(0, resource) ... num_resources = len(book.fonts) ... first_resource = book.fonts[0] >>> num_resources 1 >>> first_resource.filename 'Fonts/font.ttf'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- class AudioManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
PublicationResourceManagerThe resource manager for audio in an EPUB. An implementation of the resource manager windowed for audio files.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> with EPUB(sample) as book: ... resource = create_resource(b"", "Audio/audio.mp3") ... book.audios.insert(0, resource) ... num_resources = len(book.audios) ... first_resource = book.audios[0] >>> num_resources 1 >>> first_resource.filename 'Audio/audio.mp3'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- class VideoManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
PublicationResourceManagerThe resource manager for video in an EPUB. An implementation of the resource manager windowed for video files.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> with EPUB(sample) as book: ... resource = create_resource(b"", "Video/video.mp4") ... book.videos.insert(0, resource) ... num_resources = len(book.videos) ... first_resource = book.videos[0] >>> num_resources 1 >>> first_resource.filename 'Video/video.mp4'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- class ContentDocumentManager(resources: ~collections.abc.MutableSequence[~epublib.resources.Resource], container_file: ~epublib.resources.XMLResource, package_document: ~epublib.package.resource.PackageDocument, nav_getter: ~collections.abc.Callable[[], ~epublib.nav.resource.NavigationDocument], ncx_getter: ~collections.abc.Callable[[], ~epublib.ncx.resource.NCXFile | None] = <function WindowedResourceManager.<lambda>>)¶
Bases:
WindowedResourceManager[ContentDocument]The resource manager for content documents in an EPUB. An implementation of the resource manager windowed for documents.
Typically used from an EPUB instance.
>>> from epublib import EPUB >>> from epublib.resources.create import create_resource >>> with EPUB(sample) as book: ... resource = create_resource(b"", "Text/chapter100.xhtml") ... book.documents.insert(0, resource) ... num_resources = len(book.documents) ... first_resource = book.documents[0] >>> num_resources 3 >>> first_resource.filename 'Text/chapter100.xhtml'
- Parameters:
resources – The list of all resources in this EPUB.
container_file – The container file of this EPUB.
package_document – The package document of this EPUB.
nav_getter – Callable to get the navigation document of this EPUB.
ncx_getter – A Callable to get the ncx file of this EPUB,
- base_class¶
alias of
ContentDocument