Imports rearrangements, readme reformat, basic stuff.
Smoke tests are 100/100.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
Convert .fb2 files to .lrf
|
||||
"""
|
||||
import importlib.resources
|
||||
import mimetypes
|
||||
import os
|
||||
from importlib.resources import files
|
||||
import re
|
||||
|
||||
from lxml import etree
|
||||
@@ -85,8 +85,8 @@ class FB2Input(InputFormatPlugin):
|
||||
css = re.sub(r'name\s*=\s*', 'class=', css)
|
||||
self.extract_embedded_content(doc)
|
||||
log.debug('Converting XML to HTML...')
|
||||
with open(str(files('ebook_converter')
|
||||
.joinpath('data/fb2.xsl'))) as f:
|
||||
with open(importlib.resources.files('ebook_converter') /
|
||||
'data/fb2.xsl') as f:
|
||||
ss = f.read()
|
||||
ss = ss.replace("__FB_NS__", fb_ns)
|
||||
if options.no_inline_fb2_toc:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import importlib.resources
|
||||
import os
|
||||
from importlib.resources import files
|
||||
import re
|
||||
import shutil
|
||||
|
||||
@@ -92,27 +92,24 @@ class HTMLOutput(OutputFormatPlugin):
|
||||
with open(opts.template_html_index, 'rb') as f:
|
||||
template_html_index_data = f.read()
|
||||
else:
|
||||
with open(str(files('ebook_converter')
|
||||
.joinpath('data/html_export_default_index.tmpl'))
|
||||
) as fobj:
|
||||
with open(importlib.resources.files('ebook_converter') /
|
||||
'data/html_export_default_index.tmpl') as fobj:
|
||||
template_html_index_data = fobj.read().decode()
|
||||
|
||||
if opts.template_html is not None:
|
||||
with open(opts.template_html, 'rb') as f:
|
||||
template_html_data = f.read()
|
||||
else:
|
||||
with open(str(files('ebook_converter')
|
||||
.joinpath('data/html_export_default.tmpl'))
|
||||
) as fobj:
|
||||
with open(importlib.resources.files('ebook_converter') /
|
||||
'data/html_export_default.tmpl') as fobj:
|
||||
template_html_data = fobj.read().decode()
|
||||
|
||||
if opts.template_css is not None:
|
||||
with open(opts.template_css, 'rb') as f:
|
||||
template_css_data = f.read()
|
||||
else:
|
||||
with open(str(files('ebook_converter')
|
||||
.joinpath('data/html_export_default.css'))
|
||||
) as fobj:
|
||||
with open(importlib.resources.files('ebook_converter') /
|
||||
'data/html_export_default.css') as fobj:
|
||||
template_css_data = fobj.read().decode()
|
||||
|
||||
template_html_index_data = template_html_index_data.decode('utf-8')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import importlib.resources
|
||||
import os
|
||||
import sys
|
||||
from importlib.resources import files
|
||||
|
||||
from lxml import etree
|
||||
|
||||
@@ -52,8 +52,8 @@ class LRFInput(InputFormatPlugin):
|
||||
|
||||
self.log.info('Converting XML to HTML...')
|
||||
|
||||
with open(str(files('ebook_converter')
|
||||
.joinpath('data/lrf.xsl'))) as fobj:
|
||||
with open(importlib.resources.files('ebook_converter') /
|
||||
'data/lrf.xsl') as fobj:
|
||||
# TODO(gryf): change this nonsense to etree.parse() instead.
|
||||
styledoc = etree.fromstring(fobj.read())
|
||||
media_type = MediaType()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import importlib.resources
|
||||
import glob
|
||||
import os
|
||||
from importlib.resources import files
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
@@ -288,8 +288,8 @@ class RTFInput(InputFormatPlugin):
|
||||
|
||||
self.log.info('Converting XML to HTML...')
|
||||
inline_class = InlineClass(self.log)
|
||||
with open(str(files('ebook_converter')
|
||||
.joinpath('data/rtf.xsl'))) as fobj:
|
||||
with open(importlib.resources.files('ebook_converter') /
|
||||
'data/rtf.xsl') as fobj:
|
||||
styledoc = etree.fromstring(fobj.read())
|
||||
extensions = {('calibre', 'inline-class'): inline_class}
|
||||
transform = etree.XSLT(styledoc, extensions=extensions)
|
||||
|
||||
Reference in New Issue
Block a user