U
    a+d                     @   sl   d Z ddlZddlZddlZddlmZ eddZedk	r`ede	 ej
eddd  d	d
 ZdS )a  
Here you can find documentation on how to write your own plugin to allow
ImageIO to access a new backend. Plugins are quite object oriented, and
the relevant classes and their interaction are documented here:

.. currentmodule:: imageio

.. autosummary::
    :toctree: ../_autosummary
    :template: better_class.rst

    imageio.core.Format
    imageio.core.Request

.. note::
    You can always check existing plugins if you want to see examples.

What methods to implement
-------------------------

To implement a new plugin, create a new class that inherits from
:class:`imageio.core.Format`. and implement the following functions:

.. autosummary::
    :toctree: ../_autosummary

    imageio.core.Format.__init__
    imageio.core.Format._can_read
    imageio.core.Format._can_write

Further, each format contains up to two nested classes; one for reading and
one for writing. To support reading and/or writing, the respective classes
need to be defined.

For reading, create a nested class that inherits from
``imageio.core.Format.Reader`` and that implements the following functions:

    * Implement ``_open(**kwargs)`` to initialize the reader. Deal with the
        user-provided keyword arguments here.
    * Implement ``_close()`` to clean up.
    * Implement ``_get_length()`` to provide a suitable length based on what
        the user expects. Can be ``inf`` for streaming data.
    * Implement ``_get_data(index)`` to return an array and a meta-data dict.
    * Implement ``_get_meta_data(index)`` to return a meta-data dict. If index
        is None, it should return the 'global' meta-data.

For writing, create a nested class that inherits from
``imageio.core.Format.Writer`` and implement the following functions:

    * Implement ``_open(**kwargs)`` to initialize the writer. Deal with the
        user-provided keyword arguments here.
    * Implement ``_close()`` to clean up.
    * Implement ``_append_data(im, meta)`` to add data (and meta-data).
    * Implement ``_set_meta_data(meta)`` to set the global meta-data.

    N   )formatsZIMAGEIO_FORMAT_ORDERzSetting plugin priority through an environment variable is deprecated and will be removed in ImageIO v3. There is no replacement planned for this feature. If you have an active use-case for it, please reach out to us on GitHub. ,c              	   C   sD   zt d|  W S  tk
r>   tdt d|  ddY nX dS )a!  Lazy-Import Plugins

    This function dynamically loads plugins into the imageio.plugin
    namespace upon first access. For example, the following snippet will
    delay importing freeimage until the second line:

    >>> import imageio
    >>> imageio.plugins.freeimage.download()

    zimageio.plugins.zmodule 'z' has no attribute ''N)	importlibimport_moduleImportErrorAttributeError__name__)name r   </tmp/pip-unpacked-wheel-xbmu82vq/imageio/plugins/__init__.py__getattr__X   s    r   )__doc__r   oswarningsr   r   getenvZenv_plugin_orderwarnDeprecationWarningsortsplitr   r   r   r   r   <module>   s   9