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
|
||||
|
||||
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():
|
||||
recs.append(['input_encoding', self.site_customization.strip(),
|
||||
OptionRecommendation.HIGH])
|
||||
gui_convert(htmlfile, tdir, recs)
|
||||
gui_convert(htmlfile, tdir, recs, abort_after_input_dump=True)
|
||||
of = self.temporary_file('_plugin_html2zip.zip')
|
||||
tdir = os.path.join(tdir, 'input')
|
||||
opf = glob.glob(os.path.join(tdir, '*.opf'))[0]
|
||||
ncx = glob.glob(os.path.join(tdir, '*.ncx'))
|
||||
if ncx:
|
||||
|
@ -68,7 +68,7 @@ class Plumber(object):
|
||||
]
|
||||
|
||||
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 output: Path to output file/directory
|
||||
@ -78,6 +78,7 @@ class Plumber(object):
|
||||
self.output = os.path.abspath(output)
|
||||
self.log = log
|
||||
self.ui_reporter = report_progress
|
||||
self.abort_after_input_dump = abort_after_input_dump
|
||||
|
||||
# Initialize the conversion options that are independent of input and
|
||||
# output formats. The input and output plugins can still disable these
|
||||
@ -716,6 +717,8 @@ OptionRecommendation(name='language',
|
||||
accelerators, tdir)
|
||||
if self.opts.debug_pipeline is not None:
|
||||
self.dump_input(self.oeb, tdir)
|
||||
if self.abort_after_input_dump:
|
||||
return
|
||||
if self.input_fmt == 'recipe':
|
||||
self.opts_to_mi(self.user_metadata)
|
||||
if not hasattr(self.oeb, 'manifest'):
|
||||
|
@ -17,7 +17,7 @@ class MOBIInput(InputFormatPlugin):
|
||||
from calibre.ebooks.mobi.reader import MobiReader
|
||||
from lxml import html
|
||||
mr = MobiReader(stream, log, options.input_encoding,
|
||||
options.debug_input)
|
||||
options.debug_pipeline)
|
||||
parse_cache = {}
|
||||
mr.extract_content('.', parse_cache)
|
||||
raw = parse_cache.pop('calibre_raw_mobi_markup', False)
|
||||
|
@ -50,10 +50,10 @@ class TXTInput(InputFormatPlugin):
|
||||
htmlfile.write(html.encode('utf-8'))
|
||||
htmlfile.close()
|
||||
cwd = os.getcwdu()
|
||||
odi = options.debug_input
|
||||
options.debug_input = None
|
||||
odi = options.debug_pipeline
|
||||
options.debug_pipeline = None
|
||||
oeb = html_input(open(htmlfile.name, 'rb'), options, 'html', log,
|
||||
{}, cwd)
|
||||
options.debug_input = odi
|
||||
options.debug_pipeline = odi
|
||||
os.remove(htmlfile.name)
|
||||
return oeb
|
||||
|
@ -8,10 +8,12 @@ from calibre.ebooks.conversion.plumber import Plumber, DummyReporter
|
||||
from calibre.utils.logging import Log
|
||||
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.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.run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user