# Copyright (C) 2001-2006 Python Software Foundation
# Contact: email-sig@python.org
"""Various types of useful iterators and generators."""
'typed_subpart_iterator',
# Do not include _structure() since it's part of the debugging API.
# This function will become a method of the Message class
"""Walk over the message tree, yielding each subpart.
The walk is performed in depth-first order. This method is a
for subpart in self.get_payload():
yield from subpart.walk()
# These two functions are imported into the Iterators.py interface module.
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(decode=decode)
if isinstance(payload, str):
yield from StringIO(payload)