]> granicus.if.org Git - python/commitdiff
body_line_iterator(): Accept optional decode argument, pass through to
authorBarry Warsaw <barry@python.org>
Tue, 11 Mar 2003 04:41:35 +0000 (04:41 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 11 Mar 2003 04:41:35 +0000 (04:41 +0000)
Message.get_payload().

Lib/email/_compat21.py
Lib/email/_compat22.py

index d220723793a0ebdf11e79ca696cdc508568daba6..7cead23b937a19271316bbc027d156436748c4fd 100644 (file)
@@ -37,11 +37,14 @@ def _isstring(obj):
 \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)
index a05451f25d9637a40cdd63c0bc27edc79455a21a..ec2d2f8a0a9e52b583f521714b2c15840547ae4a 100644 (file)
@@ -38,10 +38,13 @@ def _isstring(obj):
 \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