Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/core/__pycache__/events.cpython-39.pyc
Ðазад
a o�h� � @ s` d Z G dd� de�Zi Zdd� Zedd� �Zedd� �Zed d � �Zedd� �Zed d� �Z dS )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 @ s2 e Zd ZdZddd�Zdd� Zdd� Zd d � ZdS ) �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 C s || _ dd� |D �| _|| _dS )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 S s i | ] }|g �qS � r )�.0�nr r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/core/events.py� <dictcomp>) � z)EventManager.__init__.<locals>.<dictcomp>N)�shell� callbacks�print_on_error)�selfr �available_eventsr r r r �__init__ s zEventManager.__init__c C s6 t |�std| ��|| j| vr2| j| �|� dS )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. zNeed a callable, got %rN)�callable� TypeErrorr �append�r �event�functionr r r �register, s zEventManager.registerc C s2 || j | v r| j | �|�S td�||���dS )z'Remove a callback from the given event.z0Function {!r} is not registered as a {} callbackN)r �remove� ValueError�formatr r r r � unregisterC s zEventManager.unregisterc O sj | j | dd� D ]R}z||i |�� W q ttfyb | jrTtd�||||�� | j�� Y q0 qdS )z�Call 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�funcr r r �triggerJ s ��zEventManager.triggerN)T)�__name__� __module__�__qualname__�__doc__r r r r r r r r r s r c C s | t | j<