This commit is contained in:
Kovid Goyal 2010-01-28 19:52:04 -07:00
parent de2e424c88
commit 813e52bbf8
3 changed files with 13 additions and 6 deletions

View File

@ -132,6 +132,9 @@ def prints(*args, **kwargs):
try: try:
arg = arg.encode(enc) arg = arg.encode(enc)
except UnicodeEncodeError: except UnicodeEncodeError:
try:
arg = arg.encode('utf-8')
except:
if not safe_encode: if not safe_encode:
raise raise
arg = repr(arg) arg = repr(arg)

View File

@ -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)

View File

@ -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:
try:
prints('Job:', self.id, self.description, 'finished', 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: