ó
è?F[c           @   sh   d  Z  d d l Z d d l Z d d l Z d e f d „  ƒ  YZ d d „ Z d „  Z	 e
 a d „  Z d S(   s  
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.
iÿÿÿÿNt   Pluginc           B   s#   e  Z d  Z g  Z e d „  ƒ Z RS(   s   Base class for all plugins.c         C   s(   x! | D] } | |  j  k r t Sq Wt S(   sM   Returns true if the requested capability is supported by this plugin
        (   t
   capabilityt   Falset   True(   t   clst   requested_capabilityt   c(    (    s*   lib/python2.7/site-packages/boto/plugin.pyt
   is_capable1   s    (   t   __name__t
   __module__t   __doc__R   t   classmethodR   (    (    (    s*   lib/python2.7/site-packages/boto/plugin.pyR    ,   s   c         C   sO   | s g  } n  g  } x3 |  j  ƒ  D]% } | j | ƒ r" | j | ƒ q" q" W| S(   N(   t   __subclasses__R   t   append(   R   R   t   resultt   handler(    (    s*   lib/python2.7/site-packages/boto/plugin.pyt
   get_plugin;   s    	c         C   sƒ   t  j j |  ƒ \ } } t  j j | ƒ \ } } t j | | g ƒ \ } }  } z t j | | |  | ƒ SWd  | r~ | j ƒ  n  Xd  S(   N(   t   ost   patht   splitt   splitextt   impt   find_modulet   load_modulet   close(   t   filenameR   t   namet   extt   filet   data(    (    s*   lib/python2.7/site-packages/boto/plugin.pyt   _import_moduleE   s    c         C   so   t  r
 d  St a  |  j d d ƒ s& d  S|  j d d ƒ } x0 t j t j j | d ƒ ƒ D] } t | ƒ qW Wd  S(   NR    t   plugin_directorys   *.py(	   t   _plugin_loadedR   t
   has_optiont   gett   globR   R   t   joinR   (   t   configt	   directoryR   (    (    s*   lib/python2.7/site-packages/boto/plugin.pyt   load_pluginsS   s    %(   R
   R#   R   t   os.pathR   t   objectR    t   NoneR   R   R   R    R'   (    (    (    s*   lib/python2.7/site-packages/boto/plugin.pyt   <module>%   s   
	