mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Plumber: Dummy mode that loads all options from all formats so that the default values will be set in preferences.
This commit is contained in:
parent
eb896d010f
commit
5dbc4252a7
@ -7,7 +7,8 @@ import os, re, sys
|
||||
|
||||
from calibre.customize.conversion import OptionRecommendation, DummyReporter
|
||||
from calibre.customize.ui import input_profiles, output_profiles, \
|
||||
plugin_for_input_format, plugin_for_output_format
|
||||
plugin_for_input_format, plugin_for_output_format, \
|
||||
available_input_formats, available_output_formats
|
||||
from calibre.ebooks.conversion.preprocess import HTMLPreProcessor
|
||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||
from calibre import extract, walk
|
||||
@ -50,7 +51,7 @@ class Plumber(object):
|
||||
'tags', 'book_producer', 'language'
|
||||
]
|
||||
|
||||
def __init__(self, input, output, log, report_progress=DummyReporter()):
|
||||
def __init__(self, input, output, log, report_progress=DummyReporter(), dummy=False):
|
||||
'''
|
||||
:param input: Path to input file.
|
||||
:param output: Path to output file/directory
|
||||
@ -419,12 +420,28 @@ OptionRecommendation(name='list_recipes',
|
||||
self.input_fmt = input_fmt
|
||||
self.output_fmt = output_fmt
|
||||
|
||||
|
||||
self.all_format_options = set()
|
||||
self.input_options = set()
|
||||
self.output_options = set()
|
||||
# Build set of all possible options. Two options are equal if their
|
||||
# names are the same.
|
||||
self.input_options = self.input_plugin.options.union(
|
||||
self.input_plugin.common_options)
|
||||
self.output_options = self.output_plugin.options.union(
|
||||
if not dummy:
|
||||
self.input_options = self.input_plugin.options.union(
|
||||
self.input_plugin.common_options)
|
||||
self.output_options = self.output_plugin.options.union(
|
||||
self.output_plugin.common_options)
|
||||
else:
|
||||
for fmt in available_input_formats():
|
||||
input_plugin = plugin_for_input_format(fmt)
|
||||
if input_plugin:
|
||||
self.all_format_options = self.all_format_options.union(
|
||||
input_plugin.options.union(input_plugin.common_options))
|
||||
for fmt in available_output_formats():
|
||||
output_plugin = plugin_for_output_format(fmt)
|
||||
if output_plugin:
|
||||
self.all_format_options = self.all_format_options.union(
|
||||
output_plugin.options.union(output_plugin.common_options))
|
||||
|
||||
# Remove the options that have been disabled by recommendations from the
|
||||
# plugins.
|
||||
@ -469,7 +486,7 @@ OptionRecommendation(name='list_recipes',
|
||||
|
||||
def get_option_by_name(self, name):
|
||||
for group in (self.input_options, self.pipeline_options,
|
||||
self.output_options):
|
||||
self.output_options, self.all_format_options):
|
||||
for rec in group:
|
||||
if rec.option == name:
|
||||
return rec
|
||||
@ -535,7 +552,7 @@ OptionRecommendation(name='list_recipes',
|
||||
'''
|
||||
self.opts = OptionValues()
|
||||
for group in (self.input_options, self.pipeline_options,
|
||||
self.output_options):
|
||||
self.output_options, self.all_format_options):
|
||||
for rec in group:
|
||||
setattr(self.opts, rec.option.name, rec.recommended_value)
|
||||
|
||||
|
@ -39,7 +39,7 @@ class ConfigTabs(QTabWidget):
|
||||
log = Log()
|
||||
log.outputs = []
|
||||
|
||||
self.plumber = Plumber('dummt.epub', 'dummy.epub', log)
|
||||
self.plumber = Plumber('dummy.epub', 'dummy.epub', log, dummy=True)
|
||||
|
||||
def widget_factory(cls):
|
||||
return cls(self, self.plumber.get_option_by_name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user