Skip to content

module library

Library of books.

Global Variables

  • SUBFOLDERS
  • BOOKS_SUBFOLDERS

class Library

Books and authors.

method __init__

__init__(
    folder: Optional[Path] = None,
    log: Optional[Log] = None,
    templates: Optional[TemplateSet] = None
)  None

Load books from folder if specified.

Without folder is fully functional host for book objects except saving to files. That mode is convenient for templates utilization and for tests.

if templates is not provided, builtin templates will be used.


method author_factory

author_factory(name: str)  AuthorFile

Get author object by name.

Produce author objects for books and series objects. Store already created objects in self.authors.


method author_file_mask

author_file_mask()  str

Return Author file mask.


method book_file_mask

book_file_mask()  str

Return Book file mask.


method check_templates

check_templates()  None

Check templates and regexes.


method create_author_file

create_author_file(book: Book)  AuthorFile

Create author file if id does not exist.

Do not change already existed file.

Return True if author file was added, False otherwise


method create_book_file

create_book_file(book: Book)  str

Create book file.

Return the filename.


method dump

dump(books: GoodreadsBooks)  None

Save books to the library folder.


method is_series_file_name

is_series_file_name(file_name: Path)  bool

Return True if file_name is series file name.


method load_authors

load_authors(folder: Path)  Dict[str, AuthorFile]

Load existed authors.

Return loaded authors


method load_books

load_books(folder: Path, authors: Dict[str, AuthorFile])  Dict[str, BookFile]

Load existed books.

Look for goodreads book ID inside files. Return {id: BookFile} for files with book ID, ignore other files. This way we ignore "- series" files and unknown files.


method load_series

load_series(folder: Path, authors: Dict[str, AuthorFile])  None

Load existed series.

Add them to authors. Could add series with the same title to the same author if they are in different files.


method merge_author_names

merge_author_names()  None

Replace all author names (translations, misspellings) with primary name.

To use this feature, list all author name links in one file by copying them from other author files. The name from the first link will serve as the primary name.

Author names and links in book and series files will be updated to match the primary name. Author files with non-primary names will be deleted.


method series_file_mask

series_file_mask()  str

Return Book file mask.


This file was automatically generated via lazydocs.