module templates
Templates.
Global Variables
- DEFAULT_BUILTIN_TEMPLATE
- TEMPLATES_PACKAGE_DATA_FOLDER
- CONFIG_FILE_NAME
- BOOK_TEMPLATE_FILE_NAME
- AUTHOR_TEMPLATE_FILE_NAME
- SERIES_TEMPLATE_FILE_NAME
class RegEx
Regular expression.
Auto compile regex.
method __init__
__init__(regex: str) → None
class AuthorNamesRegEx
Regular expression for name links inside author's file.
method __init__
__init__(regex: str, name_group: int) → None
class BookSeriesRegEx
Regular expression for series links inside review file.
method __init__
__init__(regex: str, series_group: int) → None
class BookGoodreadsLinkRegEx
Regular expression for goodreads links inside review file.
method __init__
__init__(
regex: str,
book_id_group: int,
title_group: int,
author_group: int
) → None
class SeriesFileNameRegEx
Regular expressions for series file name.
We only match it so no need in any groups.
method __init__
__init__(regex: str) → None
class SeriesContentRegEx
Regular expressions for series file.
method __init__
__init__(regex: str, title_group: int, author_group: int) → None
class RegExList
List of regular expressions.
method choose_regex
choose_regex(content: str) → Optional[~RegExSubClass]
Choose regex that matches the content.
class FileTemplate
Template for file with file name, optional link and body.
1st line - template for the file name.
If 2nd line is not empty - it is template for link to the file to use inside other file. Otherwise, the link is file name without extension and folders part.
After file name and optional link templates should be empty line and then file body template.
method __init__
__init__(template: str, jinja: Environment) → None
method render_body
render_body(context: Dict[str, Any]) → str
Render file body with context.
method render_file_link
render_file_link(context: Dict[str, Any]) → str
Render link with context.
If link template is not defined, return file name without extension and folder.
method render_file_name
render_file_name(context: Dict[str, Any]) → Path
Render file name with context.
class AuthorTemplate
Author template.
method __init__
__init__(
template: str,
jinja: Environment,
names_regexes: RegExList[AuthorNamesRegEx]
) → None
method render_body
render_body(context: Dict[str, Any]) → str
Render file body with context.
method render_file_link
render_file_link(context: Dict[str, Any]) → str
Render link with context.
If link template is not defined, return file name without extension and folder.
method render_file_name
render_file_name(context: Dict[str, Any]) → Path
Render file name with context.
class SeriesTemplate
Series template.
method __init__
__init__(
template: str,
jinja: Environment,
content_regexes: RegExList[SeriesContentRegEx],
file_name_regexes: RegExList[SeriesFileNameRegEx]
) → None
method render_body
render_body(context: Dict[str, Any]) → str
Render file body with context.
method render_file_link
render_file_link(context: Dict[str, Any]) → str
Render link with context.
If link template is not defined, return file name without extension and folder.
method render_file_name
render_file_name(context: Dict[str, Any]) → Path
Render file name with context.
class BookTemplate
Book template.
method __init__
__init__(
template: str,
jinja: Environment,
goodreads_link_regexes: RegExList[BookGoodreadsLinkRegEx],
series_regexes: RegExList[BookSeriesRegEx]
) → None
method render_body
render_body(context: Dict[str, Any]) → str
Render file body with context.
method render_file_link
render_file_link(context: Dict[str, Any]) → str
Render link with context.
If link template is not defined, return file name without extension and folder.
method render_file_name
render_file_name(context: Dict[str, Any]) → Path
Render file name with context.
class TemplateSet
Template set for all library objects.
method __init__
__init__(
name: str,
author: AuthorTemplate,
book: BookTemplate,
series: SeriesTemplate
) → None
class TemplatesLoader
Templates loader.
method __init__
__init__(debug: bool = False) → None
Init jinja environment.
classmethod builtin_folder
builtin_folder(builtin_name: str) → Traversable
Folder with built-in template.
method load_builtin
load_builtin(builtin_name: str = 'default') → TemplateSet
Load built-in template with the name builtin_name
.
From the goodreads-export package data folder templates
. Raise exception if no such template.
method load_folder
load_folder(folder: Union[Traversable, Path]) → TemplateSet
Load templates from the folder.
This file was automatically generated via lazydocs.