
    Mh{                         d Z  G d d          Zi Zd Zed             Zed             Zed             Zed             Zed             Zd	S )
ao  Infrastructure for registering and firing callbacks on application events.

Unlike :mod:`IPython.core.hooks`, which lets end users set single functions to
be called at specific times, or a collection of alternative methods to try,
callbacks are designed to be used by extension authors. A number of callbacks
can be registered for the same event without needing to be aware of one another.

The functions defined in this module are no-ops indicating the names of available
events and the arguments which will be passed to them.

.. note::

   This API is experimental in IPython 2.0, and may be revised in future versions.
c                   ,    e Zd ZdZddZd Zd Zd ZdS )	EventManagera3  Manage a collection of events and a sequence of callbacks for each.
    
    This is attached to :class:`~IPython.core.interactiveshell.InteractiveShell`
    instances as an ``events`` attribute.
    
    .. note::

       This API is experimental in IPython 2.0, and may be revised in future versions.
    Tc                 D    || _         d |D             | _        || _        dS )a  Initialise the :class:`CallbackManager`.

        Parameters
        ----------
        shell
            The :class:`~IPython.core.interactiveshell.InteractiveShell` instance
        available_events
            An iterable of names for callback events.
        print_on_error:
            A boolean flag to set whether the EventManager will print a warning which a event errors.
        c                     i | ]}|g S  r   ).0ns     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/core/events.py
<dictcomp>z)EventManager.__init__.<locals>.<dictcomp>)   s    9991!B999    N)shell	callbacksprint_on_error)selfr   available_eventsr   s       r	   __init__zEventManager.__init__   s/     
99(8999,r   c                     t          |          st          d|z            || j        |         vr"| j        |                             |           dS dS )a  Register a new event callback.

        Parameters
        ----------
        event : str
            The event for which to register this callback.
        function : callable
            A function to be called on the given event. It should take the same
            parameters as the appropriate callback prototype.

        Raises
        ------
        TypeError
            If ``function`` is not callable.
        KeyError
            If ``event`` is not one of the known events.
        zNeed a callable, got %rN)callable	TypeErrorr   appendr   eventfunctions      r	   registerzEventManager.register,   sd    $ !! 	B5@AAA4>%000N5!((22222 10r   c                     || j         |         v r | j         |                             |          S t          d                    ||                    )z'Remove a callback from the given event.z0Function {!r} is not registered as a {} callback)r   remove
ValueErrorformatr   s      r	   
unregisterzEventManager.unregisterC   sP    t~e,,,>%(//999KRRS[]bccdddr   c           
          | j         |         dd         D ]g}	  ||i | # t          t          f$ rH | j        r%t	          d                    ||||                     | j                                         Y dw xY wdS )zCall callbacks for ``event``.

        Any additional arguments are passed to all callbacks registered for this
        event. Exceptions raised by callbacks are caught, and a message printed.
        Nz@Error in callback {} (for {}), with arguments args {},kwargs {}:)r   	ExceptionKeyboardInterruptr   printr   r   showtraceback)r   r   argskwargsfuncs        r	   triggerzEventManager.triggerJ   s     N5)!!!, 
	+ 
	+D	+d%f%%%%01 + + +& Zaa %v   
 
((*****+
	+ 
	+s   "AA;:A;N)T)__name__
__module____qualname____doc__r   r   r   r'   r   r   r	   r   r      sb         - - - - 3 3 3.e e e+ + + + +r   r   c                 $    | t           | j        <   | S )N)r   r(   )callback_functions    r	   _define_eventr.   _   s    3D&/0r   c                      dS )zFires before code is executed in response to user/frontend action.

    This includes comm and widget messages and silent execution, as well as user
    code cells.
    Nr   r   r   r	   pre_executer0   j   	     	Dr   c                     dS )zFires before user-entered code runs.

    Parameters
    ----------
    info : :class:`~IPython.core.interactiveshell.ExecutionInfo`
        An object containing information used for the code execution.
    Nr   )infos    r	   pre_run_cellr4   s   	     	Dr   c                      dS )zFires after code is executed in response to user/frontend action.

    This includes comm and widget messages and silent execution, as well as user
    code cells.
    Nr   r   r   r	   post_executer7   ~   r1   r   c                     dS )zFires after user-entered code runs.

    Parameters
    ----------
    result : :class:`~IPython.core.interactiveshell.ExecutionResult`
        The object which will be returned as the execution result.
    Nr   )results    r	   post_run_cellr:      r5   r   c                     dS )aK  Fires after initialisation of :class:`~IPython.core.interactiveshell.InteractiveShell`.

    This is before extensions and startup scripts are loaded, so it can only be
    set by subclassing.

    Parameters
    ----------
    ip : :class:`~IPython.core.interactiveshell.InteractiveShell`
        The newly initialised shell.
    Nr   )ips    r	   shell_initializedr=      s	     	Dr   N)	r+   r   r   r.   r0   r4   r7   r:   r=   r   r   r	   <module>r>      s     I+ I+ I+ I+ I+ I+ I+ I+X     	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	r   