TCR, PDB (PalmDoc, zTXT) Input: Call TXT plugin while setting default values for options that are not set by calling plugin.

This commit is contained in:
John Schember 2011-01-05 18:39:55 -05:00
parent d23ce51b98
commit 3bb40c9911
3 changed files with 24 additions and 5 deletions

View File

@ -62,7 +62,13 @@ class Reader(FormatReader):
self.log.info('Converting text to OEB...')
stream = StringIO(raw_txt)
from calibre.customize.ui import plugin_for_input_format
txt_plugin = plugin_for_input_format('txt')
for option in txt_plugin.options:
if not hasattr(self.options, option.option.name):
setattr(self.options, option.name, option.recommend_val)
stream.seek(0)
return plugin_for_input_format('txt').convert(stream, self.options,
'txt', self.log, {})
return txt_plugin.convert(stream, self.options, 'txt', self.log, {})

View File

@ -79,7 +79,13 @@ class Reader(FormatReader):
self.log.info('Converting text to OEB...')
stream = StringIO(raw_txt)
from calibre.customize.ui import plugin_for_input_format
txt_plugin = plugin_for_input_format('txt')
for option in txt_plugin.options:
if not hasattr(self.options, option.option.name):
setattr(self.options, option.name, option.recommend_val)
stream.seek(0)
return plugin_for_input_format('txt').convert(stream, self.options,
'txt', self.log, {})
return txt_plugin.convert(stream, self.options, 'txt', self.log, {})

View File

@ -41,7 +41,14 @@ class TCRInput(InputFormatPlugin):
log.info('Converting text to OEB...')
stream = StringIO(raw_txt)
from calibre.customize.ui import plugin_for_input_format
txt_plugin = plugin_for_input_format('txt')
for option in txt_plugin.options:
if not hasattr(options, option.option.name):
setattr(options, option.name, option.recommend_val)
stream.seek(0)
return plugin_for_input_format('txt').convert(stream, options,
return txt_plugin.convert(stream, options,
'txt', log, accelerators)