🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

ebook-tree-parser

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ebook-tree-parser

Parse an ebook based on its TOC into a tree-like structure

0.1.2
Maintainers
1

ebook-tree-parser

use ebooklib to parse a tree-like structure from ebooks from the TOC

Usage

from ebooklib import epub
from ebook_tree_parser.toctree import TocTree

file = "../data/frankenstein.epub"
book = epub.read_epub(file, options={'ignore_ncx': False})

estimator = lambda string: len(string)*4
tree = TocTree(book, token_estimator=estimator)

print(tree)

for node in tree3:
    print("----")
    print(f"{node.title}|{node.content_token_count}\n{node.content[:50]}")
    print("----")

Development

  • Create a virtual environment
  • pip install -e .
  • Make sure to update pyproject.toml with the correct dependencies

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts