mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-03-01 20:44:01 +01:00
...
This commit is contained in:
parent
de2e424c88
commit
813e52bbf8
3 changed files with 13 additions and 6 deletions
|
|
@ -132,9 +132,12 @@ def prints(*args, **kwargs):
|
|||
try:
|
||||
arg = arg.encode(enc)
|
||||
except UnicodeEncodeError:
|
||||
if not safe_encode:
|
||||
raise
|
||||
arg = repr(arg)
|
||||
try:
|
||||
arg = arg.encode('utf-8')
|
||||
except:
|
||||
if not safe_encode:
|
||||
raise
|
||||
arg = repr(arg)
|
||||
|
||||
file.write(arg)
|
||||
if i != len(args)-1:
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ def load_path(self, path, pos=0.0):
|
|||
mt = guess_type(path)[0]
|
||||
html = open(path, 'rb').read().decode(path.encoding, 'replace')
|
||||
html = EntityDeclarationProcessor(html).processed_html
|
||||
has_svg = re.search(r'<\S*svg', html) is not None
|
||||
has_svg = re.search(r'<[:a-z]*svg', html) is not None
|
||||
|
||||
if 'xhtml' in mt:
|
||||
html = self.self_closing_pat.sub(self.self_closing_sub, html)
|
||||
|
|
@ -522,6 +522,7 @@ def load_path(self, path, pos=0.0):
|
|||
self.manager.load_started()
|
||||
self.loading_url = QUrl.fromLocalFile(path)
|
||||
if has_svg:
|
||||
prints('Rendering as XHTML...')
|
||||
self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path))
|
||||
else:
|
||||
self.setHtml(html, self.loading_url)
|
||||
|
|
|
|||
|
|
@ -52,10 +52,13 @@ def update(self, consume_notifications=True):
|
|||
else:
|
||||
self._status_text = _('Error') if self.failed else _('Finished')
|
||||
if DEBUG:
|
||||
prints('Job:', self.id, self.description, 'finished',
|
||||
try:
|
||||
prints('Job:', self.id, self.description, 'finished',
|
||||
safe_encode=True)
|
||||
prints('\t'.join(self.details.splitlines(True)),
|
||||
prints('\t'.join(self.details.splitlines(True)),
|
||||
safe_encode=True)
|
||||
except:
|
||||
pass
|
||||
if not self._done_called:
|
||||
self._done_called = True
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue