\dWDdZgdZddlZddlmZdZd dZd d Zd d ZdS)z1Various types of useful iterators and generators.)body_line_iteratortyped_subpart_iteratorwalkN)StringIOc#K|V|r1|D]}|Ed{VdSdS)zWalk over the message tree, yielding each subpart. The walk is performed in depth-first order. This method is a generator. N) is_multipart get_payloadr)selfsubparts ..\python\lib\email\iterators.pyrrsw JJJ &'')) & &G||~~ % % % % % % % %&& & &Fc#K|D]B}||}t|trt |Ed{VCdS)zIterate over the parts, returning string payloads line-by-line. Optional decode (default False) is passed through to .get_payload(). )decodeN)rr isinstancestrr)msgrr payloads r rr"sr 88::))%%V%44 gs # # )(( ( ( ( ( ( ( ())r textc#K|D]8}||kr|||kr|V9dS)zIterate over the subparts with a given MIME type. Use `maintype' as the main MIME type to match against; this defaults to "text". Optional `subtype' is the MIME subtype to match against; if omitted, only the main type is matched. N)rget_content_maintypeget_content_subtype)rmaintypesubtyper s r rr-se88::  ' ' ) )X 5 5'"="="?"?7"J"J r cv| tj}d|dzz}t||zd||r'td|z|nt||r,|D]}t|||dz|dSdS) zA handy debugging aidN )endfilez [%s])r)sysstdoutprintget_content_typeget_default_typerr _structure)rfplevelinclude_defaulttabr s r r&r&;s z Z  C #$$&& &BR8888 g,,...R88888 2 >(( > >G wE!G_ = = = =>> > >r )F)rN)NrF) __doc____all__r!iorrrrr&r r r/s 87     & & &))))     > > > > > >r