summaryrefslogtreecommitdiffstats
path: root/Doc/includes/email-read-alternative.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-09-26 04:15:52 (GMT)
committerGitHub <noreply@github.com>2022-09-26 04:15:52 (GMT)
commitcf61fa278e0a19a4aa5cb7cbd5c98ff2a84d481d (patch)
tree4529e906d4bd0b44dc147acd2df05f990bbaa8a1 /Doc/includes/email-read-alternative.py
parent54bb8f9af4f0198aa5f1f6b6710f8a109ae8f261 (diff)
downloadcpython-cf61fa278e0a19a4aa5cb7cbd5c98ff2a84d481d.zip
cpython-cf61fa278e0a19a4aa5cb7cbd5c98ff2a84d481d.tar.gz
cpython-cf61fa278e0a19a4aa5cb7cbd5c98ff2a84d481d.tar.bz2
gh-82530: Create blank function instead of invalid import for email example (GH-97529)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit 2b428a1faed88f148ede131e3b86ab6227c6c3f0) Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Diffstat (limited to 'Doc/includes/email-read-alternative.py')
-rw-r--r--Doc/includes/email-read-alternative.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Doc/includes/email-read-alternative.py b/Doc/includes/email-read-alternative.py
index 5ea84e6..8d0b4e6 100644
--- a/Doc/includes/email-read-alternative.py
+++ b/Doc/includes/email-read-alternative.py
@@ -8,8 +8,15 @@ import webbrowser
from email import policy
from email.parser import BytesParser
-# An imaginary module that would make this work and be safe.
-from imaginary import magic_html_parser
+
+def magic_html_parser(html_text, partfiles):
+ """Return safety-sanitized html linked to partfiles.
+
+ Rewrite the href="cid:...." attributes to point to the filenames in partfiles.
+ Though not trivial, this should be possible using html.parser.
+ """
+ raise NotImplementedError("Add the magic needed")
+
# In a real program you'd get the filename from the arguments.
with open('outgoing.msg', 'rb') as fp:
@@ -62,9 +69,6 @@ else:
print("Don't know how to display {}".format(richest.get_content_type()))
sys.exit()
with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
- # The magic_html_parser has to rewrite the href="cid:...." attributes to
- # point to the filenames in partfiles. It also has to do a safety-sanitize
- # of the html. It could be written using html.parser.
f.write(magic_html_parser(body.get_content(), partfiles))
webbrowser.open(f.name)
os.remove(f.name)