U
    3ìd—
  ã                   @   sN   d Z ddlZddlZddlZG dd„ deƒZddd„Zdd„ Zd	a	d
d„ Z
dS )a  
Implements plugin related api.

To define a new plugin just subclass Plugin, like this.

class AuthPlugin(Plugin):
    pass

Then start creating subclasses of your new plugin.

class MyFancyAuth(AuthPlugin):
    capability = ['sign', 'vmac']

The actual interface is duck typed.
é    Nc                   @   s    e Zd ZdZg Zedd„ ƒZdS )ÚPluginzBase class for all plugins.c                 C   s   |D ]}|| j kr dS qdS )zMReturns true if the requested capability is supported by this plugin
        FT)Ú
capability)ÚclsÚrequested_capabilityÚc© r   ú//tmp/pip-unpacked-wheel-d7dsrkjd/boto/plugin.pyÚ
is_capable1   s    
zPlugin.is_capableN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úclassmethodr	   r   r   r   r   r   ,   s   r   c                 C   s2   |sg }g }|   ¡ D ]}| |¡r| |¡ q|S ©N)Ú__subclasses__r	   Úappend)r   r   ÚresultÚhandlerr   r   r   Ú
get_plugin;   s    
r   c                 C   s\   t j | ¡\}}t j |¡\}}t ||g¡\}} }zt ||| |¡W ¢S |rV| ¡  X d S r   )ÚosÚpathÚsplitÚsplitextÚimpÚfind_moduleÚcloseÚload_module)Úfilenamer   ÚnameÚextÚfileÚdatar   r   r   Ú_import_moduleE   s    r"   Fc                 C   sN   t rd S da |  dd¡sd S |  dd¡}t tj |d¡¡D ]}t|ƒ q<d S )NTr   Zplugin_directoryz*.py)Ú_plugin_loadedÚ
has_optionÚgetÚglobr   r   Újoinr"   )ÚconfigÚ	directoryr    r   r   r   Úload_pluginsS   s    r*   )N)r   r&   r   Úos.pathr   Úobjectr   r   r"   r#   r*   r   r   r   r   Ú<module>   s   

