
    JeP                     `    d Z ddlZddlmZ ddlmZ  ej                  e      Z G d d      Z	y)z(
Spyder API plugin registration mixins.
    N)SpyderAPIError)Pluginsc                   .    e Zd ZdZd ZdefdZdefdZy)SpyderPluginObservera  
    This mixin enables a class to receive notifications when a plugin
    is available, by registering methods using the
    :function:`spyder.api.plugin_registration.decorators.on_plugin_available`
    decorator.

    When any of the requested plugins is ready, the corresponding registered
    method is called.

    Notes
    -----
    This mixin will only operate over the plugin requirements listed under
    `REQUIRES` and `OPTIONAL` class constants.
    c           
         i | _         i | _        t        |       D ]/  }t        | |d       }t	        |d      r|j
                  }| j                  t        j                  k7  r0|| j                  | j                  z   vrt        d| d|  d| d      t        j                  d| d|        || j                   |<   t	        |d      s|j                  }| j                  t        j                  k7  r0|| j                  | j                  z   vrt        d| d|  d| d      t        j                  d| d|        || j                  |<   2 y )	N_plugin_listenzMethod z of z is trying to watch plugin z9, but that plugin is not listed in REQUIRES nor OPTIONAL.z is watching plugin _plugin_teardownz! will handle plugin teardown for )_plugin_listeners_plugin_teardown_listenersdirgetattrhasattrr   NAMEr   LayoutREQUIRESOPTIONALr   loggerdebugr	   )selfmethod_namemethodplugin_listenplugin_teardowns        G/usr/lib/python3/dist-packages/spyder/api/plugin_registration/mixins.py__init__zSpyderPluginObserver.__init__$   st   !#*,'t9 +	OKT;5Fv/0 & 5 5 II/"$--$--*GG(!+d4& 9""/ 1;<  k]*>}oN 9D&&}5v12"("9"9 II/$DMMDMM,II(!+d4& 9""1!2 3;<  w{m 4--<,=? @CN//@W+	O    pluginc                     || j                   v r:| j                   |   }t        | |      }t        j                  d|         |        d| j                   v r$| j                   d   }t        | |      } ||       yy)z
        Handle plugin availability and redirect it to plugin-specific
        startup handlers.

        Parameters
        ----------
        plugin: str
            Name of the plugin that was notified as available.
        Calling __allN)r
   r   r   r   r   r   r   r   s       r   _on_plugin_availablez)SpyderPluginObserver._on_plugin_availableT   s~     T+++008KT;/FLL8F8,-H d,,,009KT;/F6N -r   c                     || j                   v r;| j                   |   }t        | |      }t        j                  d|         |        yy)z
        Handle plugin teardown and redirect it to plugin-specific teardown
        handlers.

        Parameters
        ----------
        plugin: str
            Name of the plugin that is going through its teardown process.
        r   N)r   r   r   r   r!   s       r   _on_plugin_teardownz(SpyderPluginObserver._on_plugin_teardownk   sK     T44499&AKT;/FLL8F8,-H	 5r   N)__name__
__module____qualname____doc__r   strr"   r$    r   r   r   r      s&    .O`3 .# r   r   )
r(   loggingspyder.api.exceptionsr   spyder.api.pluginsr   	getLoggerr%   r   r   r*   r   r   <module>r/      s3   
  0 &			8	$f fr   