U
    Z$d}  ã                   @   sP   d 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.
é    Né   )Ú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 | jkrdS d S ©NT©Ú	extensionÚ
extensions©ÚselfÚrequest© r   ú;/tmp/pip-unpacked-wheel-zwww1ayp/imageio/plugins/example.pyÚ	_can_read   s    zDummyFormat._can_readc                 C   s   |j | jkrdS d S r   r   r
   r   r   r   Ú
_can_write8   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.ReaderFé   c                 C   s   | j  ¡ | _|| _d | _d S ©N)r   Úget_fileÚ_fpÚ_lengthÚ_data)r   Zsome_optionÚlengthr   r   r   Ú_openG   s    zDummyFormat.Reader._openc                 C   s   d S r   r   ©r   r   r   r   Ú_closeS   s    zDummyFormat.Reader._closec                 C   s   | j S r   )r   r   r   r   r   Ú_get_lengthX   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_data\   s    

zDummyFormat.Reader._get_datac                 C   s   i S r   r   )r   r!   r   r   r   Ú_get_meta_datai   s    z!DummyFormat.Reader._get_meta_dataN)Fr   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r#   r$   r   r   r   r   ÚReaderF   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 r   )r   r   r   )r   Úflagsr   r   r   r   q   s    zDummyFormat.Writer._openc                 C   s   d S r   r   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   ÚWriterp   s   

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