def view_source (self, url, line, col):
"""View URL source in editor window."""
self.editor.setWindowTitle(u"View %s" % url)
self.editor.setUrl(url)
data, info = urlutil.get_content(url, proxy=self.config["proxy"])
if data is None:
msg = u"An error occurred retreiving URL `%s': %s." % (url, info)
self.editor.setText(msg)
else:
content_type = httputil.get_content_type(info)
if not content_type:
# read function for content type guessing
read = lambda: data
content_type = mimeutil.guess_mimetype(url, read=read)
self.editor.setContentType(content_type)
self.editor.setText(data, line=line, col=col)
self.editor.show()
评论列表
文章目录