summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-03-11 04:41:35 (GMT)
committerBarry Warsaw <barry@python.org>2003-03-11 04:41:35 (GMT)
commit12dc230c00c12b1c608ee0a09352ded895693bce (patch)
treeec899161ff1da3836583abaa8960bfcd83dce25e /Lib/email
parent52b39f5b47202a0c55511bb527b3e1a8140ab43f (diff)
downloadcpython-12dc230c00c12b1c608ee0a09352ded895693bce.zip
cpython-12dc230c00c12b1c608ee0a09352ded895693bce.tar.gz
cpython-12dc230c00c12b1c608ee0a09352ded895693bce.tar.bz2
body_line_iterator(): Accept optional decode argument, pass through to
Message.get_payload().
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/_compat21.py9
-rw-r--r--Lib/email/_compat22.py9
2 files changed, 12 insertions, 6 deletions
diff --git a/Lib/email/_compat21.py b/Lib/email/_compat21.py
index d220723..7cead23 100644
--- a/Lib/email/_compat21.py
+++ b/Lib/email/_compat21.py
@@ -37,11 +37,14 @@ def _isstring(obj):
# These two functions are imported into the Iterators.py interface module.
# The Python 2.2 version uses generators for efficiency.
-def body_line_iterator(msg):
- """Iterate over the parts, returning string payloads line-by-line."""
+def body_line_iterator(msg, decode=False):
+ """Iterate over the parts, returning string payloads line-by-line.
+
+ Optional decode (default False) is passed through to .get_payload().
+ """
lines = []
for subpart in msg.walk():
- payload = subpart.get_payload()
+ payload = subpart.get_payload(decode=decode)
if _isstring(payload):
for line in StringIO(payload).readlines():
lines.append(line)
diff --git a/Lib/email/_compat22.py b/Lib/email/_compat22.py
index a05451f..ec2d2f8 100644
--- a/Lib/email/_compat22.py
+++ b/Lib/email/_compat22.py
@@ -38,10 +38,13 @@ def _isstring(obj):
# These two functions are imported into the Iterators.py interface module.
# The Python 2.2 version uses generators for efficiency.
-def body_line_iterator(msg):
- """Iterate over the parts, returning string payloads line-by-line."""
+def body_line_iterator(msg, decode=False):
+ """Iterate over the parts, returning string payloads line-by-line.
+
+ Optional decode (default False) is passed through to .get_payload().
+ """
for subpart in msg.walk():
- payload = subpart.get_payload()
+ payload = subpart.get_payload(decode=decode)
if _isstring(payload):
for line in StringIO(payload):
yield line