mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix various regression in 0.6.9 caused by the new conversion debug framework
This commit is contained in:
parent
af66168ff5
commit
753466ab06
@ -27,12 +27,13 @@ every time you add an HTML file to the library.\
|
|||||||
from calibre.ebooks.epub import initialize_container
|
from calibre.ebooks.epub import initialize_container
|
||||||
|
|
||||||
with TemporaryDirectory('_plugin_html2zip') as tdir:
|
with TemporaryDirectory('_plugin_html2zip') as tdir:
|
||||||
recs =[('debug_input', tdir, OptionRecommendation.HIGH)]
|
recs =[('debug_pipeline', tdir, OptionRecommendation.HIGH)]
|
||||||
if self.site_customization and self.site_customization.strip():
|
if self.site_customization and self.site_customization.strip():
|
||||||
recs.append(['input_encoding', self.site_customization.strip(),
|
recs.append(['input_encoding', self.site_customization.strip(),
|
||||||
OptionRecommendation.HIGH])
|
OptionRecommendation.HIGH])
|
||||||
gui_convert(htmlfile, tdir, recs)
|
gui_convert(htmlfile, tdir, recs, abort_after_input_dump=True)
|
||||||
of = self.temporary_file('_plugin_html2zip.zip')
|
of = self.temporary_file('_plugin_html2zip.zip')
|
||||||
|
tdir = os.path.join(tdir, 'input')
|
||||||
opf = glob.glob(os.path.join(tdir, '*.opf'))[0]
|
opf = glob.glob(os.path.join(tdir, '*.opf'))[0]
|
||||||
ncx = glob.glob(os.path.join(tdir, '*.ncx'))
|
ncx = glob.glob(os.path.join(tdir, '*.ncx'))
|
||||||
if ncx:
|
if ncx:
|
||||||
|
@ -68,7 +68,7 @@ class Plumber(object):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, input, output, log, report_progress=DummyReporter(),
|
def __init__(self, input, output, log, report_progress=DummyReporter(),
|
||||||
dummy=False, merge_plugin_recs=True):
|
dummy=False, merge_plugin_recs=True, abort_after_input_dump=False):
|
||||||
'''
|
'''
|
||||||
:param input: Path to input file.
|
:param input: Path to input file.
|
||||||
:param output: Path to output file/directory
|
:param output: Path to output file/directory
|
||||||
@ -78,6 +78,7 @@ class Plumber(object):
|
|||||||
self.output = os.path.abspath(output)
|
self.output = os.path.abspath(output)
|
||||||
self.log = log
|
self.log = log
|
||||||
self.ui_reporter = report_progress
|
self.ui_reporter = report_progress
|
||||||
|
self.abort_after_input_dump = abort_after_input_dump
|
||||||
|
|
||||||
# Initialize the conversion options that are independent of input and
|
# Initialize the conversion options that are independent of input and
|
||||||
# output formats. The input and output plugins can still disable these
|
# output formats. The input and output plugins can still disable these
|
||||||
@ -716,6 +717,8 @@ OptionRecommendation(name='language',
|
|||||||
accelerators, tdir)
|
accelerators, tdir)
|
||||||
if self.opts.debug_pipeline is not None:
|
if self.opts.debug_pipeline is not None:
|
||||||
self.dump_input(self.oeb, tdir)
|
self.dump_input(self.oeb, tdir)
|
||||||
|
if self.abort_after_input_dump:
|
||||||
|
return
|
||||||
if self.input_fmt == 'recipe':
|
if self.input_fmt == 'recipe':
|
||||||
self.opts_to_mi(self.user_metadata)
|
self.opts_to_mi(self.user_metadata)
|
||||||
if not hasattr(self.oeb, 'manifest'):
|
if not hasattr(self.oeb, 'manifest'):
|
||||||
|
@ -17,7 +17,7 @@ class MOBIInput(InputFormatPlugin):
|
|||||||
from calibre.ebooks.mobi.reader import MobiReader
|
from calibre.ebooks.mobi.reader import MobiReader
|
||||||
from lxml import html
|
from lxml import html
|
||||||
mr = MobiReader(stream, log, options.input_encoding,
|
mr = MobiReader(stream, log, options.input_encoding,
|
||||||
options.debug_input)
|
options.debug_pipeline)
|
||||||
parse_cache = {}
|
parse_cache = {}
|
||||||
mr.extract_content('.', parse_cache)
|
mr.extract_content('.', parse_cache)
|
||||||
raw = parse_cache.pop('calibre_raw_mobi_markup', False)
|
raw = parse_cache.pop('calibre_raw_mobi_markup', False)
|
||||||
|
@ -50,10 +50,10 @@ class TXTInput(InputFormatPlugin):
|
|||||||
htmlfile.write(html.encode('utf-8'))
|
htmlfile.write(html.encode('utf-8'))
|
||||||
htmlfile.close()
|
htmlfile.close()
|
||||||
cwd = os.getcwdu()
|
cwd = os.getcwdu()
|
||||||
odi = options.debug_input
|
odi = options.debug_pipeline
|
||||||
options.debug_input = None
|
options.debug_pipeline = None
|
||||||
oeb = html_input(open(htmlfile.name, 'rb'), options, 'html', log,
|
oeb = html_input(open(htmlfile.name, 'rb'), options, 'html', log,
|
||||||
{}, cwd)
|
{}, cwd)
|
||||||
options.debug_input = odi
|
options.debug_pipeline = odi
|
||||||
os.remove(htmlfile.name)
|
os.remove(htmlfile.name)
|
||||||
return oeb
|
return oeb
|
||||||
|
@ -8,10 +8,12 @@ from calibre.ebooks.conversion.plumber import Plumber, DummyReporter
|
|||||||
from calibre.utils.logging import Log
|
from calibre.utils.logging import Log
|
||||||
from calibre.customize.conversion import OptionRecommendation
|
from calibre.customize.conversion import OptionRecommendation
|
||||||
|
|
||||||
def gui_convert(input, output, recommendations, notification=DummyReporter()):
|
def gui_convert(input, output, recommendations, notification=DummyReporter(),
|
||||||
|
abort_after_input_dump=False):
|
||||||
recommendations = list(recommendations)
|
recommendations = list(recommendations)
|
||||||
recommendations.append(('verbose', 2, OptionRecommendation.HIGH))
|
recommendations.append(('verbose', 2, OptionRecommendation.HIGH))
|
||||||
plumber = Plumber(input, output, Log(), report_progress=notification)
|
plumber = Plumber(input, output, Log(), report_progress=notification,
|
||||||
|
abort_after_input_dump=abort_after_input_dump)
|
||||||
plumber.merge_ui_recommendations(recommendations)
|
plumber.merge_ui_recommendations(recommendations)
|
||||||
|
|
||||||
plumber.run()
|
plumber.run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user