+
    ^|i                       a  0 t $ R t^ RIHt ^ RIHtHtHtHtH	t	 ]'       d   ^ RI
HtHtHt  ! R R4      t/ tR]R&   ]	! R]R	]3,          R
7      tR R lt]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R R l4       tR# )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.
)annotations)TYPE_CHECKINGAnyCallableIterableTypeVar)ExecutionInfoExecutionResultInteractiveShellc                  N    ] tR t^tRtRR R lltR R ltR R ltR R	 ltR
t	R# )EventManagera  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.
c               (    V ^8  d   QhRRRRRRRR/# )	   shellr
   available_eventszIterable[str]print_on_errorboolreturnNone )formats   "5/usr/lib/python3/dist-packages/IPython/core/events.py__annotate__EventManager.__annotate__'   s2     - -- (- 	-
 
-    c                V    Wn         V Uu/ uF  qD. bK  	  upV n        W0n        R# u upi )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.
N)r   	callbacksr   )selfr   r   r   ns   &&&& r   __init__EventManager.__init__'   s4    " 
+?
+arE+?
 -?
s   &c               $    V ^8  d   QhRRRRRR/# r   eventstrfunctionzCallable[..., Any]r   r   r   )r   s   "r   r   r   >   s"     3 3c 3-? 3D 3r   c                    \        V4      '       g   \        RV,          4      hW P                  V,          9  d%   V P                  V,          P                  V4       R# R# )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   r#   r%   s   &&&r   registerEventManager.register>   sK    $ !!5@AA>>%00NN5!((2 1r   c               $    V ^8  d   QhRRRRRR/# r"   r   )r   s   "r   r   r   U   s'     e e e/A ed er   c                    W P                   V,          9   d#   V P                   V,          P                  V4      # \        RP                  W!4      4      h)z'Remove a callback from the given event.z0Function {!r} is not registered as a {} callback)r   remove
ValueErrorr   r*   s   &&&r   
unregisterEventManager.unregisterU   sC    ~~e,,>>%(//99KRRS[cddr   c               (    V ^8  d   QhRRRRRRRR/# )r   r#   r$   argsr   kwargsr   r   r   )r   s   "r   r   r   \   s(     + +S + + + +r   c           
        V P                   V,          R,           F  p V! V/ VB  K  	  R#   \        \        3 dL    T P                  '       d   \	        RP                  YAY#4      4       T P                  P                  4         Km  i ; i)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.
:NNNz@Error in callback {} (for {}), with arguments args {},kwargs {}:N)r   	ExceptionKeyboardInterruptr   printr   r   showtraceback)r   r#   r4   r5   funcs   &&*, r   triggerEventManager.trigger\   s     NN5)!,,D	+d%f% - 01 +&&&Zaa 
 

((*+s   -"B	5B	B	)r   r   r   N)T)
__name__
__module____qualname____firstlineno____doc__r   r+   r1   r<   __static_attributes__r   r   r   r   r      s!    -.3.e+ +r   r   zdict[str, Callable[..., Any]]r   
_CallbackT.)boundc                    V ^8  d   QhRRRR/# )r   callback_functionrD   r   r   )r   s   "r   r   r   s   s      Z J r   c                ,    V \         V P                  &   V # )zADecorator to register a function as an available event prototype.)r   r>   )rG   s   &r   _define_eventrI   s   s    3D&//0r   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r      s     	 	T 	r   c                     R# )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_executerM           	r   c                    V ^8  d   QhRRRR/# )r   infor   r   r   r   )r   s   "r   r   r      s     	 	} 	 	r   c                    R# )zFires before user-entered code runs.

Parameters
----------
info : :class:`~IPython.core.interactiveshell.ExecutionInfo`
    An object containing information used for the code execution.
Nr   )rP   s   &r   pre_run_cellrR           	r   c                   V ^8  d   QhRR/# rK   r   )r   s   "r   r   r      s     	 	d 	r   c                     R# )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_executerV      rN   r   c                    V ^8  d   QhRRRR/# )r   resultr	   r   r   r   )r   s   "r   r   r      s     	 	/ 	d 	r   c                    R# )zFires after user-entered code runs.

Parameters
----------
result : :class:`~IPython.core.interactiveshell.ExecutionResult`
    The object which will be returned as the execution result.
Nr   )rX   s   &r   post_run_cellrZ      rS   r   c                    V ^8  d   QhRRRR/# )r   ipr
   r   r   r   )r   s   "r   r   r      s     	 	* 	t 	r   c                    R# )a/  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   )r\   s   &r   shell_initializedr^      s     	r   N)__conditional_annotations__rB   
__future__r   typingr   r   r   r   r   IPython.core.interactiveshellr   r	   r
   r   r   __annotations__rD   rI   rM   rR   rV   rZ   r^   )r_   s   @r   <module>rd      s    # B B P+ P+f 35 / 4\#s();<
 	 	 	 	 	 	 	 	 	 	r   