mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-29 08:53:07 +02:00
merge
This commit is contained in:
commit
df85aacb47
9 changed files with 19 additions and 15 deletions
|
|
@ -977,6 +977,8 @@ def create_oebbook(log, path_or_stream, opts, input_plugin, reader=None,
|
|||
from calibre.ebooks.oeb.base import OEBBook
|
||||
html_preprocessor = HTMLPreProcessor(input_plugin.preprocess_html,
|
||||
opts.preprocess_html, opts)
|
||||
if not encoding:
|
||||
encoding = None
|
||||
oeb = OEBBook(log, html_preprocessor,
|
||||
pretty_print=opts.pretty_print, input_encoding=encoding)
|
||||
if not populate:
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ def __init__(self, path_to_html_file, level, encoding, verbose, referrer=None):
|
|||
|
||||
self.is_binary = level > 0 and not bool(self.HTML_PAT.search(src[:4096]))
|
||||
if not self.is_binary:
|
||||
if encoding is None:
|
||||
if not encoding:
|
||||
encoding = xml_to_unicode(src[:4096], verbose=verbose)[-1]
|
||||
self.encoding = encoding
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ def __init__(self, raw, ident, user_encoding, log, try_extra_data_fix=False):
|
|||
65001: 'utf-8',
|
||||
}[self.codepage]
|
||||
except (IndexError, KeyError):
|
||||
self.codec = 'cp1252' if user_encoding is None else user_encoding
|
||||
self.codec = 'cp1252' if not user_encoding else user_encoding
|
||||
log.warn('Unknown codepage %d. Assuming %s' % (self.codepage,
|
||||
self.codec))
|
||||
if ident == 'TEXTREAD' or self.length < 0xE4 or 0xE8 < self.length \
|
||||
|
|
|
|||
|
|
@ -1892,7 +1892,7 @@ def fix_data(d):
|
|||
return fix_data(data.decode(bom_enc))
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
if self.input_encoding is not None:
|
||||
if self.input_encoding:
|
||||
try:
|
||||
return fix_data(data.decode(self.input_encoding, 'replace'))
|
||||
except UnicodeDecodeError:
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ def extract_content(self, output_dir):
|
|||
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.recommended_value)
|
||||
for opt in txt_plugin.options:
|
||||
if not hasattr(self.options, opt.option.name):
|
||||
setattr(self.options, opt.option.name, opt.recommended_value)
|
||||
|
||||
stream.seek(0)
|
||||
return txt_plugin.convert(stream, self.options, 'txt', self.log, {})
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ def extract_content(self, output_dir):
|
|||
from calibre.customize.ui import plugin_for_input_format
|
||||
|
||||
pdf_plugin = plugin_for_input_format('pdf')
|
||||
for option in pdf_plugin.options:
|
||||
if not hasattr(self.options, option.option.name):
|
||||
setattr(self.options, option.name, option.recommended_value)
|
||||
for opt in pdf_plugin.options:
|
||||
if not hasattr(self.options, opt.option.name):
|
||||
setattr(self.options, opt.option.name, opt.recommended_value)
|
||||
|
||||
pdf.seek(0)
|
||||
return pdf_plugin.convert(pdf, self.options, 'pdf', self.log, {})
|
||||
|
|
|
|||
|
|
@ -83,9 +83,9 @@ def extract_content(self, output_dir):
|
|||
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.recommended_value)
|
||||
for opt in txt_plugin.options:
|
||||
if not hasattr(self.options, opt.option.name):
|
||||
setattr(self.options, opt.option.name, opt.recommended_value)
|
||||
|
||||
stream.seek(0)
|
||||
return txt_plugin.convert(stream, self.options, 'txt', self.log, {})
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ def convert(self, stream, options, file_ext, log, accelerators):
|
|||
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.recommended_value)
|
||||
for opt in txt_plugin.options:
|
||||
if not hasattr(self.options, opt.option.name):
|
||||
setattr(self.options, opt.option.name, opt.recommended_value)
|
||||
|
||||
stream.seek(0)
|
||||
return txt_plugin.convert(stream, options,
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ def get_value(self, g):
|
|||
codecs.lookup(ans)
|
||||
except:
|
||||
ans = ''
|
||||
if not ans:
|
||||
ans = None
|
||||
return ans
|
||||
elif isinstance(g, QComboBox):
|
||||
return unicode(g.currentText())
|
||||
|
|
|
|||
Loading…
Reference in a new issue