ó
½-'Nc           @   sf   d  d l  m Z d  d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 S(
   iÿÿÿÿ(   t   info(   t   format_objectt   PluginConfigErrorc           B   s   e  Z d  Z RS(   s7   There was an error registering or configuring a plugin.(   t   __name__t
   __module__t   __doc__(    (    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyR      s   t   PluginRegistryc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s(   A central integration point for plugins.c         C   s   g  |  _  i  |  _ d  S(   N(   t   _pluginst   _plugin_names(   t   self(    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyt   __init__   s    	c         C   sV   t  d t | ƒ ƒ |  j j | ƒ t | d ƒ rE | |  j | j <n  | j |  ƒ d S(   s  Register a plugin.

        The plugin's C{register} method will be called with this registry as
        its argument.

        If the plugin has a C{plugin_name} attribute, it will be possible to
        look up the plugin later with L{get_plugin}.
        s   Registering plugin %s.t   plugin_nameN(   R    R   R   t   appendt   hasattrR   R   t   register(   R	   t   plugin(    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyt   add   s
    	c         C   s   |  j  S(   s   Get the list of plugins.(   R   (   R	   (    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyt   get_plugins    s    c         C   s   |  j  | S(   s    Get a particular plugin by name.(   R   (   R	   t   name(    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyt
   get_plugin$   s    (   R   R   R   R
   R   R   R   (    (    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyR   
   s
   			t   Pluginc           B   s   e  Z d  Z d Z d „  Z RS(   s˜  A convenience for writing plugins.

    This provides a register method which will set up a bunch of
    reactor handlers in the idiomatic way.

    If C{run} is defined on subclasses, it will be called every C{run_interval}
    seconds after being registered.

    @cvar run_interval: The interval, in seconds, to execute the
    C{run} method. If set to C{None}, then C{run} will not be
    scheduled.
    i   c         C   sG   | |  _  t |  d ƒ rC |  j d  k	 rC | j j |  j |  j ƒ n  d  S(   Nt   run(   t   registryR   t   run_intervalt   Nonet   reactort
   call_everyR   (   R	   R   (    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyR   9   s    	(   R   R   R   R   R   (    (    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyR   )   s   N(	   t   loggingR    t   landscape.logR   t	   ExceptionR   t   objectR   R   (    (    (    s4   /usr/lib/python2.7/dist-packages/landscape/plugin.pyt   <module>   s   