Clean up mhtml doc and use email.message.Message
MIMEMultipart is not needed for the attachements, a simple Message is enough. Also fix the README markup and the _start_download docstring.
This commit is contained in:
parent
e68965fea2
commit
5acc982b44
@ -103,6 +103,7 @@ The following software and libraries are required to run qutebrowser:
|
|||||||
* http://pyyaml.org/wiki/PyYAML[PyYAML]
|
* http://pyyaml.org/wiki/PyYAML[PyYAML]
|
||||||
|
|
||||||
The following libraries are optional and provide a better user experience:
|
The following libraries are optional and provide a better user experience:
|
||||||
|
|
||||||
* http://cthedot.de/cssutils/[cssutils]
|
* http://cthedot.de/cssutils/[cssutils]
|
||||||
|
|
||||||
To generate the documentation for the `:help` command, when using the git
|
To generate the documentation for the `:help` command, when using the git
|
||||||
|
@ -30,6 +30,7 @@ import email.policy
|
|||||||
import email.generator
|
import email.generator
|
||||||
import email.encoders
|
import email.encoders
|
||||||
import email.mime.multipart
|
import email.mime.multipart
|
||||||
|
import email.message
|
||||||
|
|
||||||
from PyQt5.QtCore import QUrl
|
from PyQt5.QtCore import QUrl
|
||||||
|
|
||||||
@ -205,11 +206,10 @@ class MHTMLWriter:
|
|||||||
return self._create_file(root_file)
|
return self._create_file(root_file)
|
||||||
|
|
||||||
def _create_file(self, f):
|
def _create_file(self, f):
|
||||||
"""Return the single given file as MIMEMultipart."""
|
"""Return the single given file as email.message.Message."""
|
||||||
msg = email.mime.multipart.MIMEMultipart()
|
msg = email.message.Message()
|
||||||
|
msg['MIME-Version'] = '1.0'
|
||||||
msg['Content-Location'] = f.content_location
|
msg['Content-Location'] = f.content_location
|
||||||
# Get rid of the default type multipart/mixed
|
|
||||||
del msg['Content-Type']
|
|
||||||
if f.content_type:
|
if f.content_type:
|
||||||
msg.set_type(f.content_type)
|
msg.set_type(f.content_type)
|
||||||
msg.set_payload(f.content)
|
msg.set_payload(f.content)
|
||||||
@ -475,7 +475,7 @@ def _start_download(dest, web_view):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
dest: The filename where the resulting file should be saved.
|
dest: The filename where the resulting file should be saved.
|
||||||
win_id, tab_id: Specify the tab whose page should be loaded.
|
web_view: Specify the webview whose page should be loaded.
|
||||||
"""
|
"""
|
||||||
loader = _Downloader(web_view, dest)
|
loader = _Downloader(web_view, dest)
|
||||||
loader.run()
|
loader.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user