o ,], @szdZddlmZddlmZddlmZddlmZgdZddlZddlm Z d d Z dd d Z dddZ dddZ dS)z1Various types of useful iterators and generators.)print_function)unicode_literals)division)absolute_import)body_line_iteratortyped_subpart_iteratorwalkN)StringIOccs:|V|r|D]}|D]}|Vqq dSdS)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)selfsubpart subsubpartrB/usr/lib/python3/dist-packages/future/backports/email/iterators.pyrs  rFccs>|D]}|j|d}t|trt|D]}|VqqdS)zIterate over the parts, returning string payloads line-by-line. Optional decode (default False) is passed through to .get_payload(). )decodeN)rr isinstancestrr )msgrr payloadlinerrrr%s    rtextccs:|D]}||kr|dus||kr|VqdS)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 rrrr1s  rcCs|durtj}d|d}t||d|d|r%td||dnt|d|r>|D] }t|||d|q2dSdS) zA handy debugging aidN )endfilez [%s])r )sysstdoutprintget_content_typeget_default_typer r _structure)rfplevelinclude_defaulttabr rrrr'>s   r')F)rN)NrF)__doc__ __future__rrrr__all__r"ior rrrr'rrrrs