Book

class encyclopaedia.book.Book(number: int | None = None, parent: Encyclopaedia | None = None, title: str = '', subject: str = '', locked: bool = False, locked_persistent: bool | None = False, locked_title: str = '???')[source]

Bases: EventEmitter, object

Container for EncEntry which have a strong relationship with each other.

A Book should be placed inside an Encyclopaedia. When sorted and/or filtered, the Book’s attributes will be used.

Parameters:
number: int | None = None

The Book’s number.

parent: Encyclopaedia | None = None

The parent container for the Book.

title: str = ''

A name for the Book.

subject: str = ''

The subject to associate the Book with.

locked: bool = False

The initial locked status of the Book.

locked_persistent: bool | None = False

Use persistent data for recording locked status.

locked_title: str = '???'

Placeholder text for the title. Shown when the Book is locked.

property active : EncEntry

Get the object for the currently active page.

Raises:

GetEntryError – If no active page could be found.

add_entry(entry: EncEntry) bool[source]

Add an EncEntry to this Book.

Returns:

True if the operation was a success

Raises:

AddEntryError

property current_page : EncEntry

Alias for active. Used by screens.

property locked : bool

The locked status of the Book.

property name : str

Alias for title, used for sorting in an Encyclopaedia.

next_page() bool[source]

Set the next page as the current page.

property percentage_unlocked : float

Get the percentage of the Book’s pages which are unlocked.

Returns:

Number between 0.0 and 1.0

Raises:

ZeroDivisionError – If the Book is empty

previous_page() bool[source]

Set the previous page as the current page.

set_active_page(page_number: int) None[source]

Set a page to be active, based on the page number.

Parameters:
page_number: int

The number of the page to set.

property title : str

The title of the Book.

property viewed : bool

Determine if the Book has been viewed or not.

Returns:

False if any page in the Book has not been viewed, else True.

property word_count : int

Get the word count for the entire Book.

All the text from all the pages in the book will be counted.

Returns:

The number of words in the Book.