%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/blinker/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/blinker/__pycache__/base.cpython-35.pyc



C��Q�9�@s�dZddlmZddlmZddlmZmZmZm	Z	m
Z
mZmZed�Z
de
_dZGdd�de�Zed	�ZGd
d�de�ZGdd
�d
e�ZGdd�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�eZdZdZeZedd��Zedd��Zddd�Zed	d
d�Z	dd
d�Z
eedd��Zedd�Z
dd�Zdd�Zdd�Zedd�Zdd�Zdd�Zdd �Zd!d"�ZdS)#�SignalzA notification emitter.cCs
tdd�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

        �docz"Emitted after a receiver connects.)r)�self�r�./usr/lib/python3/dist-packages/blinker/base.py�receiver_connected%s
zSignal.receiver_connectedcCs
tdd�S)aEmitted 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

        r
z%Emitted after a receiver disconnects.)r)rrrr�receiver_disconnected1szSignal.receiver_disconnectedNcCsC|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)rr
rrr�__init__Is		zSignal.__init__TcCs�t|�}|r0t||j�}||_n|}|tkrKt}nt|�}|jj||�|j|j	|�|j
|j	|�~|tk	r�||jkr�yt||j�}||_
Wntk
r�YnX|jj||�~d|jkrY|jjrYy&|jj|d|d|d|�Wn|j||��YnXtjr�|tk	r�y#tj|d|d|d|�Wn|j||��YnX|S)aaConnect *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�weakZreceiver_argZ
sender_argZweak_arg)rr	�_cleanup_receiver�receiver_idr�ANY_IDr�
setdefaultr�addrr�_cleanup_sender�	sender_id�	TypeError�__dict__r�send�
disconnect)rrrrr�receiver_refr#�
sender_refrrr�connect\sP	

zSignal.connectFcs���fdd�}|S)aKConnect 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

        cs�j|���|S)N)r*)�fn)rrrrr�	decorator�sz%Signal.connect_via.<locals>.decoratorr)rrrr,r)rrrr�connect_via�szSignal.connect_viac	csN|j|d|dd�y	dVWn|j|��YnX|j|�dS)aExecute 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

        rrFN)r*r')rrrrrr�connected_to�s	
zSignal.connected_tocCstdt�|j||�S)a_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 removed in a subsequent version.

        zAtemporarily_connected_to is deprecated; use connected_to instead.)r�DeprecationWarningr.)rrrrrr�temporarily_connected_to�s
zSignal.temporarily_connected_tocs�t��dkrd�n5t��dkrFtdt����n
�d�|js]gS��fdd�|j��D�SdS)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.

        rN�z5send() accepts only one positional argument, %s givencs%g|]}||���f�qSrr)�.0r)�kwargsrrr�
<listcomp>
s	zSignal.send.<locals>.<listcomp>)�lenr$r�
receivers_for)rrr3r)r3rrr&�s	
	zSignal.sendcCsA|js
dS|jtrdS|tkr.dSt|�|jkS)z�True if there is probably a receiver for *sender*.

        Performs an optimistic check only.  Does not guarantee that all
        weakly referenced receivers are still alive.  See
        :meth:`receivers_for` for a stronger search.

        FT)rrrrr)rrrrr�has_receivers_for
s	
zSignal.has_receivers_forccs�|jr�t|�}||jkr?|jt|j|B}n|jtj�}xq|D]i}|jj|�}|dkr�qYt|t�r�|�}|dkr�|j|t�qY|}|VqYWdS)z2Iterate all live receivers listening for *sender*.N)	rrrr�copy�get�
isinstancer�_disconnect)rrr#ZidsrrZstrongrrrr6s"	

	zSignal.receivers_forcCsx|tkrt}nt|�}t|�}|j||�d|jkrt|jjrt|jj|d|d|�dS)aDisconnect *receiver* from this signal's events.

        :param receiver: a previously :meth:`connected<connect>` callable

        :param sender: a specific sender to disconnect from, or :obj:`ANY`
          to disconnect from all senders.  Defaults to ``ANY``.

        rrrN)rrrr;r%rrr&)rrrr#rrrrr'3s		zSignal.disconnectcCsv|tkr^|jj|d�rHx$|jj�D]}|j|�q1W|jj|d�n|j|j|�dS)NF)rr�popr�values�discardr)rrr#Zbucketrrrr;IszSignal._disconnectcCs|j|jt�dS)z'Disconnect a receiver from all senders.N)r;rr)rr(rrrrRszSignal._cleanup_receivercCsf|j}|tkst�|jj|d�x1|jj|f�D]}|j|j|�qDWdS)z'Disconnect all receivers from a sender.N)r#r�AssertionErrorrr<rrr>)rr)r#rrrrr"Vs
	zSignal._cleanup_sendercCs8|jj�|jj�|jj�|jj�dS)z4Throw away all signal state.  Useful for unit tests.N)r�clearrrr)rrrr�_clear_state^s


zSignal._clear_state)�__name__�
__module__�__qualname__rrrrrrr*r-rr.r0r&r7r6r'r;rr"rArrrrrs$D$	ra
Sent by a :class:`Signal` after a receiver connects.

:argument: the Signal that was connected to
:keyword receiver_arg: the connected receiver
:keyword sender_arg: the sender to connect to
:keyword weak_arg: true if the connection to receiver_arg is a weak reference

.. deprecated:: 1.2

As of 1.2, individual signals have their own private
:attr:`~Signal.receiver_connected` and
:attr:`~Signal.receiver_disconnected` signals with a slightly simplified
call signature.  This global signal is planned to be removed in 1.6.

c@s1eZdZdZddd�Zdd�ZdS)�NamedSignalz%A named generic notification emitter.NcCstj||�||_dS)N)rr�name)rrFr
rrrr{szNamedSignal.__init__cCs*tj|�}d|dd�|jfS)Nz%s; %r>r1���)r�__repr__rF)r�baserrrrH�szNamedSignal.__repr__)rBrCrDrrrHrrrrrExsrEc@s%eZdZdZddd�ZdS)�	Namespacez%A mapping of signal names to signals.NcCs>y||SWn+tk
r9|j|t||��SYnXdS)z�Return the :class:`NamedSignal` *name*, creating it if required.

        Repeated calls to this function will return the same signal object.

        N)�KeyErrorr rE)rrFr
rrr�signal�s
zNamespace.signal)rBrCrDrrLrrrrrJ�srJc@s%eZdZdZddd�ZdS)�
WeakNamespaceaA weak mapping of signal names to signals.

    Automatically cleans up unused Signals when the last reference goes out
    of scope.  This namespace implementation exists for a measure of legacy
    compatibility with Blinker <= 1.2, and may be dropped in the future.

    NcCs>y||SWn+tk
r9|j|t||��SYnXdS)z�Return the :class:`NamedSignal` *name*, creating it if required.

        Repeated calls to this function will return the same signal object.

        N)rKr rE)rrFr
rrrrL�s
zWeakNamespace.signal)rBrCrDrrLrrrrrM�srMN)r�warningsr�weakrefrZblinker._utilitiesrrrrrr	r
rr�objectrrrE�dictrJrMrLrrrr�<module>
s4	�I	

Zerion Mini Shell 1.0