mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
de2e424c88
commit
813e52bbf8
@ -132,9 +132,12 @@ def prints(*args, **kwargs):
|
|||||||
try:
|
try:
|
||||||
arg = arg.encode(enc)
|
arg = arg.encode(enc)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
if not safe_encode:
|
try:
|
||||||
raise
|
arg = arg.encode('utf-8')
|
||||||
arg = repr(arg)
|
except:
|
||||||
|
if not safe_encode:
|
||||||
|
raise
|
||||||
|
arg = repr(arg)
|
||||||
|
|
||||||
file.write(arg)
|
file.write(arg)
|
||||||
if i != len(args)-1:
|
if i != len(args)-1:
|
||||||
|
@ -514,7 +514,7 @@ class DocumentView(QWebView):
|
|||||||
mt = guess_type(path)[0]
|
mt = guess_type(path)[0]
|
||||||
html = open(path, 'rb').read().decode(path.encoding, 'replace')
|
html = open(path, 'rb').read().decode(path.encoding, 'replace')
|
||||||
html = EntityDeclarationProcessor(html).processed_html
|
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:
|
if 'xhtml' in mt:
|
||||||
html = self.self_closing_pat.sub(self.self_closing_sub, html)
|
html = self.self_closing_pat.sub(self.self_closing_sub, html)
|
||||||
@ -522,6 +522,7 @@ class DocumentView(QWebView):
|
|||||||
self.manager.load_started()
|
self.manager.load_started()
|
||||||
self.loading_url = QUrl.fromLocalFile(path)
|
self.loading_url = QUrl.fromLocalFile(path)
|
||||||
if has_svg:
|
if has_svg:
|
||||||
|
prints('Rendering as XHTML...')
|
||||||
self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path))
|
self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path))
|
||||||
else:
|
else:
|
||||||
self.setHtml(html, self.loading_url)
|
self.setHtml(html, self.loading_url)
|
||||||
|
@ -52,10 +52,13 @@ class BaseJob(object):
|
|||||||
else:
|
else:
|
||||||
self._status_text = _('Error') if self.failed else _('Finished')
|
self._status_text = _('Error') if self.failed else _('Finished')
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
prints('Job:', self.id, self.description, 'finished',
|
try:
|
||||||
|
prints('Job:', self.id, self.description, 'finished',
|
||||||
safe_encode=True)
|
safe_encode=True)
|
||||||
prints('\t'.join(self.details.splitlines(True)),
|
prints('\t'.join(self.details.splitlines(True)),
|
||||||
safe_encode=True)
|
safe_encode=True)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if not self._done_called:
|
if not self._done_called:
|
||||||
self._done_called = True
|
self._done_called = True
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user