3

‹ˆh:  ã               @   s   G d d„ dƒZ ddd„ZdS )c               @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚIteratora-  
    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   s,   t |dƒstdƒ‚|| _t| jddƒ| _d S )NÚseekzim must have seek methodZ
_min_frameé    )ÚhasattrÚAttributeErrorÚimÚgetattrÚposition)Úselfr   © r
   úQ/var/www/html/enquirykeeper_venv/lib/python3.6/site-packages/PIL/ImageSequence.pyÚ__init__   s    
zIterator.__init__c             C   s@   y| j j|ƒ | j S  tk
r: } zt|‚W Y d d }~X nX d S )N)r   r   ÚEOFErrorÚ
IndexError)r	   ÚixÚer
   r
   r   Ú__getitem__%   s
    zIterator.__getitem__c             C   s   | S )Nr
   )r	   r
   r
   r   Ú__iter__,   s    zIterator.__iter__c             C   sP   y"| j j| jƒ |  jd7  _| j S  tk
rJ } zt|‚W Y d d }~X nX d S )Né   )r   r   r   r   ÚStopIteration)r	   r   r
   r
   r   Ú__next__/   s    zIterator.__next__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r
   r
   r
   r   r      s
   
r   Nc                sd   t | tƒs| g} g }x4| D ],}|jƒ }|dd„ t|ƒD ƒ7 }|j|ƒ qW ˆ r`‡ fdd„|D ƒS |S )a  
    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.
    c             S   s   g | ]}|j ƒ ‘qS r
   )Úcopy)Ú.0Zim_framer
   r
   r   ú
<listcomp>H   s    zall_frames.<locals>.<listcomp>c                s   g | ]}ˆ |ƒ‘qS r
   r
   )r   r   )Úfuncr
   r   r   K   s    )Ú
isinstanceÚlistÚtellr   r   )r   r   ZimsZ
imSequenceÚcurrentr
   )r   r   Ú
all_frames8   s    	

r"   )N)r   r"   r
   r
   r
   r   Ú<module>   s   %