ó
è¾bc           @   sk   d  Z  d d d g Z d d l Z d d l m Z d „  Z e d „ Z d	 d d
 „ Z	 d d e d „ Z
 d S(   s1   Various types of useful iterators and generators.t   body_line_iteratort   typed_subpart_iteratort   walkiÿÿÿÿN(   t   StringIOc         c   sK   |  V|  j  ƒ  rG x3 |  j ƒ  D]" } x | j ƒ  D] } | Vq1 Wq Wn  d S(   s‰   Walk over the message tree, yielding each subpart.

    The walk is performed in depth-first order.  This method is a
    generator.
    N(   t   is_multipartt   get_payloadR   (   t   selft   subpartt
   subsubpart(    (    s%   /usr/lib/python2.7/email/iterators.pyR      s
    c         c   s[   xT |  j  ƒ  D]F } | j d | ƒ } t | t ƒ r x t | ƒ D] } | VqA Wq q Wd S(   sŽ   Iterate over the parts, returning string payloads line-by-line.

    Optional decode (default False) is passed through to .get_payload().
    t   decodeN(   R   R   t
   isinstancet
   basestringR   (   t   msgR	   R   t   payloadt   line(    (    s%   /usr/lib/python2.7/email/iterators.pyR    #   s
    t   textc         c   sV   xO |  j  ƒ  D]A } | j ƒ  | k r | d k sC | j ƒ  | k rN | VqN q q Wd S(   sø   Iterate 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(   R   t   get_content_maintypet   Nonet   get_content_subtype(   R   t   maintypet   subtypeR   (    (    s%   /usr/lib/python2.7/email/iterators.pyR   /   s    i    c         C   sœ   | d k r t j } n  d | d } | | |  j ƒ  I| rW | d |  j ƒ  IJn | J|  j ƒ  r˜ x. |  j ƒ  D] } t | | | d | ƒ qt Wn  d S(   s   A handy debugging aidt    i   s   [%s]i   N(   R   t   syst   stdoutt   get_content_typet   get_default_typeR   R   t
   _structure(   R   t   fpt   levelt   include_defaultt   tabR   (    (    s%   /usr/lib/python2.7/email/iterators.pyR   =   s    (   t   __doc__t   __all__R   t	   cStringIOR   R   t   FalseR    R   R   R   (    (    (    s%   /usr/lib/python2.7/email/iterators.pyt   <module>   s   		