
    G@dP                     d    d Z ddlZddlmZ ddlmZ  ej        e          Z G d d          Z	dS )z(
Spyder API plugin registration mixins.
    N)SpyderAPIError)Pluginsc                   0    e Zd ZdZd ZdefdZdefdZdS )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           
      l   i | _         i | _        t          |           D ]}t          | |d           }t	          |d          rp|j        }| j        t          j        k    r*|| j	        | j
        z   vrt          d| d|  d| d          t                              d| d|            || j         |<   t	          |d          rp|j        }| j        t          j        k    r*|| j	        | j
        z   vrt          d| d|  d| d          t                              d| d|            || j        |<   d S )	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        Elib/python3.11/site-packages/spyder/api/plugin_registration/mixins.py__init__zSpyderPluginObserver.__init__$   s   !#*,'t99 +	O +	OKT;55Fv/00 D & 5 I//"$-$-*GGG(<+ < <4 < <"/< < <   NkNN}NN   9D&}5v122 O"("9 I//$DMDM,III(<+ < <4 < <"1< < <    ?{ ? ?-<? ? @ @ @CN/@W+	O +	O    pluginc                    || j         v rD| j         |         }t          | |          }t                              d|             |             d| j         v r*| j         d         }t          | |          } ||           dS dS )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8KT;//FLL,F,,---FHHH d,,,09KT;//FF6NNNNN -,r   c                     || j         v rF| j         |         }t          | |          }t                              d|             |             dS dS )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   s`     T4449&AKT;//FLL,F,,---FHHHHH	 54r   N)__name__
__module____qualname____doc__r   strr"   r$    r   r   r   r      sg         .O .O .O`3    .#      r   r   )
r(   loggingspyder.api.exceptionsr   spyder.api.pluginsr   	getLoggerr%   r   r   r*   r   r   <module>r/      s    
  0 0 0 0 0 0 & & & & & &		8	$	$f f f f f f f f f fr   