Imports rearrangements, readme reformat, basic stuff.

Smoke tests are 100/100.
This commit is contained in:
gryf committed 2026-05-13 22:14:07 +02:00
1 parent 3d38ae9633
commit fa24530bc5
13 files changed
+53 -47

No files matched your search

+5 -4
View File
@@ -1,7 +1,7 @@
import collections
import functools
import importlib.resources
import operator
from importlib.resources import files
import re
import urllib.parse
@@ -719,8 +719,8 @@ def commit_nav_toc(container, toc, lang=None, landmarks=None,
if previous_nav is not None:
root = previous_nav[1]
else:
with open(str(files('ebook_converter')
.joinpath('data/new_nav.html'))) as fobj:
with open(importlib.resources.file('ebook_converter') /
'data/new_nav.html') as fobj:
root = container.parse_xhtml(fobj.read())
container.replace(tocname, root)
else:
@@ -873,7 +873,8 @@ def toc_to_html(toc, container, toc_name, title, lang=None):
E = ElementMaker(namespace=const.XHTML_NS, nsmap={None: const.XHTML_NS})
# TODO(gryf): revisit lack of css.
css_f = str(files('ebook_converter').joinpath('data/inline_toc_styles.css'))
css_f = str(importlib.resources.files('ebook_converter') /
'data/inline_toc_styles.css')
html = E.html(E.head(E.title(title),
E.style(css_f, type='text/css')),
E.body(E.h2(title), E.ul(),
+10 -3
View File
@@ -1,8 +1,14 @@
"""
CSS property propagation class.
"""
import os, re, logging, copy, unicodedata, numbers
from importlib.resources import files
import copy
import importlib.resources
import logging
import numbers
import os
import re
import unicodedata
from operator import itemgetter
from weakref import WeakKeyDictionary
from xml.dom import SyntaxErr as CSSSyntaxError
@@ -28,7 +34,8 @@ _html_css_stylesheet = None
def html_css_stylesheet():
global _html_css_stylesheet
if _html_css_stylesheet is None:
with open(str(files('ebook_converter').joinpath('data/html.css')), 'rb') as f:
with open(importlib.resources.files('ebook_converter') /
'data/html.css', 'rb') as f:
html_css = f.read().decode('utf-8')
_html_css_stylesheet = parseString(html_css, validate=False)
return _html_css_stylesheet