B
    ÿNŽ[“  ã               @   sd   d Z ddlmZmZmZ ddlZddlmZ ddl	m
Z
 G dd„ de
ƒZed	d
ddƒZe e¡ dS )zE Example plugin. You can use this as a template for your own plugin.
é    )Úabsolute_importÚprint_functionÚdivisionNé   )Úformats)ÚFormatc               @   sD   e Zd ZdZdd„ Zdd„ ZG dd„ dejƒZG dd	„ d	ejƒZd
S )ÚDummyFormata!   The dummy format is an example format that does nothing.
    It will never indicate that it can read or write a file. When
    explicitly asked to read, it will simply read the bytes. When 
    explicitly asked to write, it will raise an error.
    
    This documentation is shown when the user does ``help('thisformat')``.
    
    Parameters for reading
    ----------------------
    Specify arguments in numpy doc style here.
    
    Parameters for saving
    ---------------------
    Specify arguments in numpy doc style here.
    
    c             C   s(   |j d | jd kr$|j| jkr$dS d S )Né   ú?T)ÚmodeÚmodesÚ	extensionÚ
extensions)ÚselfÚrequest© r   ú6lib/python3.7/site-packages/imageio/plugins/example.pyÚ	_can_read!   s    zDummyFormat._can_readc             C   s(   |j d | jd kr$|j| jkr$dS d S )Nr	   r
   T)r   r   r   r   )r   r   r   r   r   Ú
_can_write<   s    	zDummyFormat._can_writec               @   s6   e Zd Zddd„Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )zDummyFormat.ReaderFr	   c             C   s   | j  ¡ | _|| _d | _d S )N)r   Úget_fileÚ_fpÚ_lengthÚ_data)r   Zsome_optionÚlengthr   r   r   Ú_openL   s    zDummyFormat.Reader._openc             C   s   d S )Nr   )r   r   r   r   Ú_closeX   s    zDummyFormat.Reader._closec             C   s   | j S )N)r   )r   r   r   r   Ú_get_length]   s    zDummyFormat.Reader._get_lengthc             C   sV   || j krtd|| j f ƒ‚| jd kr2| j ¡ | _t | jd¡}t|ƒdf|_|i fS )NzImage index %i > %iZuint8r	   )	r   Ú
IndexErrorr   r   ÚreadÚnpZ
frombufferÚlenÚshape)r   ÚindexÚimr   r   r   Ú	_get_dataa   s    

zDummyFormat.Reader._get_datac             C   s   i S )Nr   )r   r"   r   r   r   Ú_get_meta_datan   s    z!DummyFormat.Reader._get_meta_dataN)Fr	   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r$   r%   r   r   r   r   ÚReaderK   s
   
r)   c               @   s.   e Zd Zddd„Zdd„ Zdd„ Zdd	„ Zd
S )zDummyFormat.Writerr   c             C   s   | j  ¡ | _d S )N)r   r   r   )r   Úflagsr   r   r   r   v   s    zDummyFormat.Writer._openc             C   s   d S )Nr   )r   r   r   r   r   €   s    zDummyFormat.Writer._closec             C   s   t dƒ‚d S )Nz)The dummy format cannot write image data.)ÚRuntimeError)r   r#   Úmetar   r   r   Ú_append_data…   s    zDummyFormat.Writer._append_datac             C   s   t dƒ‚d S )Nz(The dummy format cannot write meta data.)r+   )r   r,   r   r   r   Úset_meta_data‰   s    z DummyFormat.Writer.set_meta_dataN)r   )r&   r'   r(   r   r   r-   r.   r   r   r   r   ÚWriteru   s   

r/   N)	r&   r'   r(   Ú__doc__r   r   r   r)   r/   r   r   r   r   r      s
   *r   Zdummyz$An example format that does nothing.z.foobar .nonexistentextZiI)r0   Z
__future__r   r   r   Znumpyr   Ú r   Zcorer   r   ÚformatZ
add_formatr   r   r   r   Ú<module>   s    