Add --debug-pipeline option to EPUB/MOBI catalog plugin

This commit is contained in:
Kovid Goyal 2010-01-23 10:39:07 -07:00
commit 26a9ec899f

View File

@ -241,6 +241,15 @@ class EPUB_MOBI(CatalogPlugin):
help = _('Title of generated catalog used as title in metadata.\n' help = _('Title of generated catalog used as title in metadata.\n'
"Default: '%default'\n" "Default: '%default'\n"
"Applies to: ePub, MOBI output formats")), "Applies to: ePub, MOBI output formats")),
Option('--debug-pipeline',
default=None,
dest='debug_pipeline',
help=_('Save the output from different stages of the conversion '
'pipeline to the specified '
'directory. Useful if you are unsure at which stage '
'of the conversion process a bug is occurring.\n'
'Default: None\n'
'Applies to: ePub, MOBI output formats')),
Option('--exclude-genre', Option('--exclude-genre',
default='\[[\w ]*\]', default='\[[\w ]*\]',
dest='exclude_genre', dest='exclude_genre',
@ -730,7 +739,6 @@ class EPUB_MOBI(CatalogPlugin):
shutil.copy(os.path.join(catalog_resources,file[1]), shutil.copy(os.path.join(catalog_resources,file[1]),
os.path.join(self.catalogPath, file[0])) os.path.join(self.catalogPath, file[0]))
def fetchBooksByTitle(self): def fetchBooksByTitle(self):
if self.verbose: if self.verbose:
@ -2544,10 +2552,10 @@ class EPUB_MOBI(CatalogPlugin):
def run(self, path_to_output, opts, db, notification=DummyReporter()): def run(self, path_to_output, opts, db, notification=DummyReporter()):
from calibre.utils.logging import Log from calibre.utils.logging import Log
self.opts = opts
log = Log() log = Log()
opts.fmt = self.fmt = path_to_output.rpartition('.')[2] opts.fmt = self.fmt = path_to_output.rpartition('.')[2]
self.opts = opts
# Add local options # Add local options
opts.creator = "calibre" opts.creator = "calibre"
@ -2561,13 +2569,18 @@ class EPUB_MOBI(CatalogPlugin):
log("%s:run" % self.name) log("%s:run" % self.name)
log(" path_to_output: %s" % path_to_output) log(" path_to_output: %s" % path_to_output)
log(" Output format: %s" % self.fmt) log(" Output format: %s" % self.fmt)
if opts_dict['ids']:
log(" Book count: %d" % len(opts_dict['ids'])) log(" Book count: %d" % len(opts_dict['ids']))
# Display opts # Display opts
keys = opts_dict.keys() keys = opts_dict.keys()
keys.sort() keys.sort()
log(" opts:") log(" opts:")
for key in keys: for key in keys:
if key == 'ids': continue if key == 'ids':
if opts_dict[key]:
continue
else:
log(" %s: (all)" % key)
log(" %s: %s" % (key, opts_dict[key])) log(" %s: %s" % (key, opts_dict[key]))
# Launch the Catalog builder # Launch the Catalog builder
@ -2578,6 +2591,11 @@ class EPUB_MOBI(CatalogPlugin):
recommendations = [] recommendations = []
dp = getattr(opts, 'debug_pipeline', None)
if dp is not None:
recommendations.append(('debug_pipeline', dp,
OptionRecommendation.HIGH))
if opts.fmt == 'mobi' and opts.output_profile and opts.output_profile.startswith("kindle"): if opts.fmt == 'mobi' and opts.output_profile and opts.output_profile.startswith("kindle"):
recommendations.append(('output_profile', opts.output_profile, recommendations.append(('output_profile', opts.output_profile,
OptionRecommendation.HIGH)) OptionRecommendation.HIGH))
@ -2592,4 +2610,3 @@ class EPUB_MOBI(CatalogPlugin):
plumber.merge_ui_recommendations(recommendations) plumber.merge_ui_recommendations(recommendations)
plumber.run() plumber.run()