blob: eed98bef92f5cba292767d5674e7ab6ede3f956e [file] [log] [blame]
Barry Warsaw5e634632001-09-26 05:23:47 +00001\declaremodule{standard}{email.Iterators}
2\modulesynopsis{Iterate over a message object tree.}
Barry Warsaw5e634632001-09-26 05:23:47 +00003
4Iterating over a message object tree is fairly easy with the
5\method{Message.walk()} method. The \module{email.Iterators} module
6provides some useful higher level iterations over message object
7trees.
8
9\begin{funcdesc}{body_line_iterator}{msg}
10This iterates over all the payloads in all the subparts of \var{msg},
11returning the string payloads line-by-line. It skips over all the
12subpart headers, and it skips over any subpart with a payload that
13isn't a Python string. This is somewhat equivalent to reading the
14flat text representation of the message from a file using
15\method{readline()}, skipping over all the intervening headers.
16\end{funcdesc}
17
18\begin{funcdesc}{typed_subpart_iterator}{msg\optional{,
19 maintype\optional{, subtype}}}
20This iterates over all the subparts of \var{msg}, returning only those
21subparts that match the MIME type specified by \var{maintype} and
22\var{subtype}.
23
24Note that \var{subtype} is optional; if omitted, then subpart MIME
25type matching is done only with the main type. \var{maintype} is
Barry Warsawc5f8fe32001-09-26 22:21:52 +000026optional too; it defaults to \mimetype{text}.
Barry Warsaw5e634632001-09-26 05:23:47 +000027
28Thus, by default \function{typed_subpart_iterator()} returns each
Barry Warsawc5f8fe32001-09-26 22:21:52 +000029subpart that has a MIME type of \mimetype{text/*}.
Barry Warsaw5e634632001-09-26 05:23:47 +000030\end{funcdesc}
31