Annotations in Epub converter

This commit is contained in:
Kiryl
2022-08-03 14:39:13 +03:00
parent 7453029295
commit 78e3ad8911
16 changed files with 259 additions and 192 deletions

View File

@@ -1,5 +1,5 @@
import re
from typing import Union
from typing import List, Dict, Union
from ebooklib.epub import Section, Link
from src.livecarta_config import LiveCartaConfig
@@ -11,7 +11,7 @@ class NavPoint:
These are data structures which form mapping from NCX to python data structures.
"""
def __init__(self, obj: Union[Link, Section] = None, ):
def __init__(self, obj: Union[Link, Section] = None):
self.href, self.id = self.parse_href_id(obj)
self.title = obj.title
@@ -52,15 +52,15 @@ def flatten(x):
class ChapterItem:
"""
Class of Chapter that could have subchapters
These are data structures which form mapping to livecarta json structure.
These are data structures which form mapping to LiveCarta json structure.
"""
def __init__(self, title, content, sub_items):
def __init__(self, title: str, content: str, sub_items: List):
self.title = title
self.content = content
self.sub_items = sub_items
def to_dict(self, lvl=1):
def to_dict(self, lvl: int = 1) -> Dict[str, Union[str, List]]:
"""Function returns dictionary of chapter"""
sub_dicts = []
if self.sub_items: