Ñò
#8Zc           @   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   		