epublib.package.guide module

class GuideItem(soup: S, tag: ~bs4.element.Tag = <sentinel/>, *, filename: str, href: ~typing.Annotated[str, ~epublib.xml_element.XMLAttribute(init_name=None, sync=<SyncType.ATTR: 1>, get=None, create=None, prefix=)] = '', own_filename: str, type: ~typing.Annotated[str, ~epublib.xml_element.XMLAttribute(init_name=None, sync=<SyncType.ATTR: 1>, get=None, create=None, prefix=)], title: ~typing.Annotated[str, ~epublib.xml_element.XMLAttribute(init_name=None, sync=<SyncType.ATTR: 1>, get=None, create=None, prefix=)])

Bases: HrefElement

An item in the EPUB guide (legacy feature).

Parameters:
  • soup – The BeautifulSoup object of which this item is part of.

  • filename – The filename of the referenced resource. If not given, it will be derived from href and own_filename. Only one of href and filename should be given.

  • href – The href of the referenced resource. If not given, it will be derived from filename and own_filename. Only one of href and filename should be given.

  • own_filename – The filename of the file containing this item.

  • title – The title of the reference.

  • type – The type of the reference

class BookGuide(
soup: S,
tag: ~bs4.element.Tag = <sentinel/>,
*,
own_filename: str,
)

Bases: ParentOfHref[GuideItem, BeautifulSoup]

The EPUB spine, which defines the linear reading order of the book.

Parameters:
  • soup – The BeautifulSoup object of which this guide is part of.

  • tag – The tag representing this guide. If not given, a new tag will be created.

  • own_filename – The filename of the file containing this guide.

add(
filename: str,
title: str,
type: str,
) GuideItem

Create a new guide item and add it to this guide.

Parameters:
  • filename – The filename of the referenced resource.

  • title – The title of the reference.

  • type – The type of the reference

Returns:

The newly created guide item.