
4ec           @   s&   d  e  f d     YZ d d  Z d S(   t   Iteratorc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s-  
    This class implements an iterator object that can be used to loop
    over an image sequence.

    You can use the ``[]`` operator to access elements by index. This operator
    will raise an :py:exc:`IndexError` if you try to access a nonexistent
    frame.

    :param im: An image object.
    c         C   sC   t  | d  s t d   n  | |  _ t |  j d d  |  _ d  S(   Nt   seeks   im must have seek methodt
   _min_framei    (   t   hasattrt   AttributeErrort   imt   getattrt   position(   t   selfR   (    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt   __init__   s    	c         C   s9   y |  j  j |  |  j  SWn t k
 r4 t  n Xd  S(   N(   R   R   t   EOFErrort
   IndexError(   R   t   ix(    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt   __getitem__%   s
    c         C   s   |  S(   N(    (   R   (    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt   __iter__,   s    c         C   sK   y- |  j  j |  j  |  j d 7_ |  j  SWn t k
 rF t  n Xd  S(   Ni   (   R   R   R   R
   t   StopIteration(   R   (    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt   __next__/   s    c         C   s
   |  j    S(   N(   R   (   R   (    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt   next7   s    (   t   __name__t
   __module__t   __doc__R	   R   R   R   R   (    (    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyR       s   
				c         C   s   t  |  t  s |  g }  n  g  } xP |  D]H } | j   } | g  t |  D] } | j   ^ qJ 7} | j |  q( W| r g  | D] }  | |   ^ q S| S(   s  
    Applies a given function to all frames in an image or a list of images.
    The frames are returned as a list of separate images.

    :param im: An image, or a list of images.
    :param func: The function to apply to all of the image frames.
    :returns: A list of images.
    (   t
   isinstancet   listt   tellR    t   copyR   (   R   t   funct   imst
   imSequencet   currentt   im_frame(    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt
   all_frames;   s    	)N(   t   objectR    t   NoneR   (    (    (    s;   /usr/local/lib/python2.7/dist-packages/PIL/ImageSequence.pyt   <module>   s   (