Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
python38
/
lib
/
python3.8
/
site-packages
/
blinker
/
__pycache__
/
//opt/alt/python38/lib/python3.8/site-packages/blinker/__pycache__/base.cpython-38.pyc
U RѰU�? � @ s� d Z ddlmZ ddlmZ ddlmZmZmZm Z m Z mZmZ ed�Z de _ dZG dd� de�Zed �ZG d d� de�ZG dd � d e�ZG dd� de�Ze� jZdS )a+ Signals and events. A small implementation of signals, inspired by a snippet of Django signal API client code seen in a blog post. Signals are first-class objects and each manages its own receivers and message emission. The :func:`signal` function provides singleton behavior for named signals. � )�warn)�WeakValueDictionary)� WeakTypes�contextmanager�defaultdict�hashable_identity� lazy_property� reference�symbol�ANYzToken for "any sender".c @ s� e Zd ZdZeZedd� �Zedd� �Zd%dd�Zed fd d�Z d&d d�Z eefdd��Zefdd�Z dd� Zdd� Zdd� Zefdd�Zdd� Zdd� Zdd � Zd!d"� Zd#d$� ZdS )'�SignalzA notification emitter.c C s t dd�S )z�Emitted after each :meth:`connect`. The signal sender is the signal instance, and the :meth:`connect` arguments are passed through: *receiver*, *sender*, and *weak*. .. versionadded:: 1.2 z"Emitted after a receiver connects.��doc�r ��self� r �=/opt/alt/python38/lib/python3.8/site-packages/blinker/base.py�receiver_connected% s zSignal.receiver_connectedc C s t dd�S )a Emitted after :meth:`disconnect`. The sender is the signal instance, and the :meth:`disconnect` arguments are passed through: *receiver* and *sender*. Note, this signal is emitted **only** when :meth:`disconnect` is called explicitly. The disconnect signal can not be emitted by an automatic disconnect (due to a weakly referenced receiver or sender going out of scope), as the receiver and/or sender instances are no longer available for use at the time this signal would be emitted. An alternative approach is available by subscribing to :attr:`receiver_connected` and setting up a custom weakref cleanup callback on weak receivers and senders. .. versionadded:: 1.2 z%Emitted after a receiver disconnects.r r r r r r �receiver_disconnected1 s zSignal.receiver_disconnectedNc C s. |r || _ i | _tt�| _tt�| _i | _dS )zt :param doc: optional. If provided, will be assigned to the signal's __doc__ attribute. N)�__doc__� receiversr �set�_by_receiver� _by_sender� _weak_senders)r r r r r �__init__I s zSignal.__init__Tc C sF t |�}|r t|| j�}||_n|}|tkr2t}nt |�}| j�||� | j| � |� | j | � |� ~|tk r�|| jkr�zt|| j�}||_ W n tk r� Y nX | j�||� ~d| jkr�| jjr�z| jj| |||d� W n | �||� � Y nX tj�rB| tk �rBztj| |||d� W n | �||� � Y nX |S )aa Connect *receiver* to signal events sent by *sender*. :param receiver: A callable. Will be invoked by :meth:`send` with `sender=` as a single positional argument and any \*\*kwargs that were provided to a call to :meth:`send`. :param sender: Any object or :obj:`ANY`, defaults to ``ANY``. Restricts notifications delivered to *receiver* to only those :meth:`send` emissions sent by *sender*. If ``ANY``, the receiver will always be notified. A *receiver* may be connected to multiple *sender* values on the same Signal through multiple calls to :meth:`connect`. :param weak: If true, the Signal will hold a weakref to *receiver* and automatically disconnect when *receiver* goes out of scope or is garbage collected. Defaults to True. r )�receiver�sender�weak)�receiver_arg� sender_arg�weak_arg)r r �_cleanup_receiver�receiver_idr �ANY_IDr � setdefaultr �addr r �_cleanup_sender� sender_id� TypeError�__dict__r �send� disconnect)r r r r r$ �receiver_refr) � sender_refr r r �connect\ sV �� � zSignal.connectFc s � ��fdd�}|S )aK Connect the decorated function as a receiver for *sender*. :param sender: Any object or :obj:`ANY`. The decorated function will only receive :meth:`send` emissions sent by *sender*. If ``ANY``, the receiver will always be notified. A function may be decorated multiple times with differing *sender* values. :param weak: If true, the Signal will hold a weakref to the decorated function and automatically disconnect when *receiver* goes out of scope or is garbage collected. Unlike :meth:`connect`, this defaults to False. The decorated function will be invoked by :meth:`send` with `sender=` as a single positional argument and any \*\*kwargs that were provided to the call to :meth:`send`. .. versionadded:: 1.1 c s � � | ��� | S �N)r0 )�fn�r r r r r � decorator� s z%Signal.connect_via.<locals>.decoratorr )r r r r4 r r3 r �connect_via� s zSignal.connect_viac c sB | j ||dd� z dV W n | �|� � Y nX | �|� dS )a Execute a block with the signal temporarily connected to *receiver*. :param receiver: a receiver callable :param sender: optional, a sender to filter on This is a context manager for use in the ``with`` statement. It can be useful in unit tests. *receiver* is connected to the signal for the duration of the ``with`` block, and will be disconnected automatically when exiting the block: .. testsetup:: from __future__ import with_statement from blinker import Signal on_ready = Signal() receiver = lambda sender: None .. testcode:: with on_ready.connected_to(receiver): # do stuff on_ready.send(123) .. versionadded:: 1.1 F)r r N)r0 r- �r r r r r r �connected_to� s zSignal.connected_toc C s t dt� | �||�S )ag An alias for :meth:`connected_to`. :param receiver: a receiver callable :param sender: optional, a sender to filter on .. versionadded:: 0.9 .. versionchanged:: 1.1 Renamed to :meth:`connected_to`. ``temporarily_connected_to`` was deprecated in 1.2 and will be removed in a subsequent version. zAtemporarily_connected_to is deprecated; use connected_to instead.)r �DeprecationWarningr7 r6 r r r �temporarily_connected_to� s �zSignal.temporarily_connected_toc s` t ��dkrd�n&t ��dkr0tdt �� ��n�d �| jsBg S � �fdd�| ���D �S dS )a� Emit this signal on behalf of *sender*, passing on \*\*kwargs. Returns a list of 2-tuples, pairing receivers with their return value. The ordering of receiver notification is undefined. :param \*sender: Any object or ``None``. If omitted, synonymous with ``None``. Only accepts one positional argument. :param \*\*kwargs: Data to be sent to receivers. r N� z5send() accepts only one positional argument, %s givenc s g | ]}||�f� �f�qS r r )�.0r ��kwargsr r r � <listcomp> s �zSignal.send.<locals>.<listcomp>)�lenr* r � receivers_for)r r r= r r<