diff --git a/qutebrowser/misc/mhtml.py b/qutebrowser/misc/mhtml.py index 9a5d19850..ce909f683 100644 --- a/qutebrowser/misc/mhtml.py +++ b/qutebrowser/misc/mhtml.py @@ -35,9 +35,9 @@ from qutebrowser.browser import webelem from qutebrowser.utils import log, objreg, message -_File = collections.namedtuple("_File", - ["content", "content_type", "content_location", - "transfer_encoding"]) +_File = collections.namedtuple('_File', + ['content', 'content_type', 'content_location', + 'transfer_encoding']) _CSS_URL_PATTERNS = [re.compile(x) for x in [ @@ -51,9 +51,7 @@ _CSS_URL_PATTERNS = [re.compile(x) for x in [ def _get_css_imports(data): """Return all assets that are referenced in the given CSS document. - The returned URLs are relative to the stylesheet's URL. - Args: data: The content of the stylesheet to scan as string. """ @@ -66,7 +64,7 @@ def _get_css_imports(data): return urls -MHTMLPolicy = policy.default.clone(linesep="\r\n", max_line_length=0) +MHTMLPolicy = policy.default.clone(linesep='\r\n', max_line_length=0) E_BASE64 = encoders.encode_base64 @@ -123,8 +121,8 @@ class MHTMLWriter(): Args: fp: The file-object, openend in "wb" mode. """ - msg = multipart.MIMEMultipart("related", - "---=_qute-{}".format(uuid.uuid4())) + msg = multipart.MIMEMultipart('related', + '---=_qute-{}'.format(uuid.uuid4())) root = self._create_root_file() msg.attach(root) @@ -146,9 +144,9 @@ class MHTMLWriter(): def _create_file(self, f): """Return the single given file as MIMEMultipart.""" msg = multipart.MIMEMultipart() - msg["Content-Location"] = f.content_location + msg['Content-Location'] = f.content_location # Get rid of the default type multipart/mixed - del msg["Content-Type"] + del msg['Content-Type'] if f.content_type: msg.set_type(f.content_type) msg.set_payload(f.content) @@ -192,7 +190,7 @@ class _Downloader(): web_frame = self.web_view.page().mainFrame() self.writer = MHTMLWriter( - web_frame.toHtml().encode("utf-8"), + web_frame.toHtml().encode('utf-8'), content_location=web_url.toString(), # I've found no way of getting the content type of a QWebView, but # since we're using .toHtml, it's probably safe to say that the @@ -201,32 +199,32 @@ class _Downloader(): ) # Currently only downloading (stylesheets),