\f
# 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)
\f
# 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