Ńň
mČKc           @   sk   d  Z  d d d g Z d d k Z d d k l 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   sM   |  V|  i    o7 x4 |  i   D]" } x | i   D] } | Vq2 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.6/email/iterators.pyR      s      c         c   s]   xV |  i    D]H } | i d |  } t | t  o  x t |  D] } | VqB 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.6/email/iterators.pyR    #   s      t   textc         c   s[   xT |  i    D]F } | i   | j o- | d j p | i   | j o	 | VqS 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.6/email/iterators.pyR   /   s
      i    c         C   s˘   | d j o t i } n d | d } | | |  i   I| o | d |  i   IJn | J|  i   o2 x/ |  i   D] } t | | | d |  qy 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.6/email/iterators.pyR   =   s     (   t   __doc__t   __all__R   t	   cStringIOR   R   t   FalseR    R   R   R   (    (    (    s%   /usr/lib/python2.6/email/iterators.pyt   <module>   s   		