%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�]ue@P��$�dZddlmZddlZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZej.r�ddlZej4dej6dej8f��Zej4d�Zej>d�Z ej6ej6e ejBefgej6e effZ"ej6ej6e efgej6e ejBeffZ#ed�Z$de$_dZ%ejLZ&Gd�d�Z'e'd�Z(Gd�de'�Z)Gd�de*�Z+Gd�de�Z,e+�jZZ-y) 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.

�)�annotationsN)�defaultdict)�contextmanager)�iscoroutinefunction)�warn)�WeakValueDictionary)�annotatable_weakref)�hashable_identity)�IdentityType)�
lazy_property)�	reference)�symbol)�	WeakTypes�
T_callable.)�bound�T�P�ANYzToken for "any sender".c�X�eZdZUdZeZeZded<edd��Z	edd��Z
ddd�Zedf							dd	�Z	d					d d
�Z
eef					d!d��Zed"d��Zef					d#d
�Zdd�							d$d�Zdd�							d%d�Zd&d�Zd'd�Z				d(d�Zefd)d�Zd*d�Zd+d�Zd,d�Zd-d�Zd-d�Zy).�SignalzA notification emitter.z	type[set]�	set_classc��td��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��selfs �./usr/lib/python3/dist-packages/blinker/base.py�receiver_connectedzSignal.receiver_connected8s���>�?�?�c��td��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

        z%Emitted after a receiver disconnects.rrrs r�receiver_disconnectedzSignal.receiver_disconnectedDs��,�A�B�Br Nc��|r||_i|_d|_t|j�|_t|j�|_i|_y)zt
        :param doc: optional.  If provided, will be assigned to the signal's
          __doc__ attribute.

        FN)�__doc__�	receivers�is_mutedrr�_by_receiver�
_by_sender�
_weak_senders)rrs  r�__init__zSignal.__init__\sY����D�L�PR�����
�CN��N�N�D
���BM��N�N�B
���GI��r Tc��t|�}|rt||j�}||_n|}|turt
}nt|�}|jj||�|j|j|�|j|j|�~|turI||jvr;	t||j�}||_
|jj||�~d|jvr6|j jr 	|j j#||||��t jr$|t ur	t j#||||��|S|S#t$rY��wxYw#t$r}|j%||�|�d}~wwxYw#t$r}|j%||�|�d}~wwxYw)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�weakN)�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)	rr,r-r.r3�receiver_refr8�
sender_ref�es	         r�connectzSignal.connectts���*(��1���$�X�t�/E�/E�F�L�'2�L�$�#�L��S�=��I�)�&�1�I����!�!�+�|�<����	�"�&�&�{�3����+�&�*�*�9�5������$�2D�2D�!D�
�&�v�t�/C�/C�D�
�'0�
�$��"�"�-�-�i��D�� �4�=�=�0�T�5L�5L�5V�5V�
��'�'�,�,��8�F��-���'�'�D�8J�,J�
�"�'�'��x�F�T�(����x���/�
��
���
�����&�1����
���
�����&�1����
�sB�8E,�E;�F �,	E8�7E8�;	F�F�F� 	G�)F=�=Gc�����d���fd�}|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

        c�.���j|���|S�N)r@)�fnrr-r.s ���r�	decoratorz%Signal.connect_via.<locals>.decorator�s����L�L��V�T�*��Ir )rDr�returnr�)rr-r.rEs``` r�connect_viazSignal.connect_via�s���0	��r c#�K�|j||d��	d��|j|�y#|j|�wxYw�w)ahExecute 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:

        .. code-block:: python

          with on_ready.connected_to(receiver):
             # do stuff
             on_ready.send(123)

        .. versionadded:: 1.1

        F)r-r.N)r@r<�rr,r-s   r�connected_tozSignal.connected_to�s<����.	
���X�f�5��9�	&��J��O�O�H�%��D�O�O�H�%�s�A�.�A�A�Ac#�rK�d|_	d��	d|_y#t$r}|�d}~wwxYw#d|_wxYw�w)z\Context manager for temporarily disabling signal.
        Useful for test purposes.
        TNF)r&�	Exception)rr?s  r�mutedzSignal.muted�sB����
��
�	"��J�"�D�M���	��G��	��"�D�M�s$�7��7�	(�#�(�+�	4�7c�F�tdt�|j||�S)agAn 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�DeprecationWarningrKrJs   r�temporarily_connected_tozSignal.temporarily_connected_tos'��	
�O��	
�� � ��6�2�2r )�_async_wrapperc���|jrgS|j|�}g}|j|�D]>}t|�r|�t	d��||�}||fi|��}|j||f��@|S)aEmit 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 _async_wrapper: A callable that should wrap a coroutine
          receiver and run it when called synchronously.

        :param kwargs: Data to be sent to receivers.
        z#Cannot send to a coroutine function�r&�_extract_sender�
receivers_forr�RuntimeError�append)rrRr-�kwargs�resultsr,�results       rr;zSignal.sends���$�=�=��I��%�%�f�-�����*�*�6�2�	/�H�"�8�,�!�)�&�'L�M�M�)�(�3���f�/��/�F��N�N�H�f�-�.�
	/��r )�
_sync_wrapperc��K�|jrgS|j|�}g}|j|�D]F}t|�s|�t	d��||�}||fi|���d{���}|j||f��H|S7��w)aEmit 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 _sync_wrapper: A callable that should wrap a synchronous
          receiver and run it when awaited.

        :param kwargs: Data to be sent to receivers.
        Nz'Cannot send to a non-coroutine functionrT)rr\r-rYrZr,r[s       r�
send_asynczSignal.send_async7s�����$�=�=��I��%�%�f�-�����*�*�6�2�	/�H�&�x�0� �(�&�'P�Q�Q�(��2��#�F�5�f�5�5�F��N�N�H�f�-�.�
	/���6�s�A"B�$B�%Bc���|js*|r&t|�dkDrtdt|��d���gSt|�dk(rd}|St|�dkDrtdt|��d���|d}|S)N�z-send() accepts only one positional argument, z givenr)r%�lenr9�rr-s  rrUzSignal._extract_senderWs����~�~�$��F��a���C�C��K�=�PV�W����I�
�v�;�!���F��
�
��[�1�_��?��F��}�F�S��
��A�Y�F��
r c��|jsy|jtry|turyt	|�|jvS)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)r%r(r4rr
rbs  r�has_receivers_forzSignal.has_receivers_forns;���~�~���?�?�6�"���S�=�� ��(�D�O�O�;�;r c#�K�|jr�t|�}||jvr$|jt|j|z}n!|jtj	�}|D]V}|jj|�}|��!t
|t�r"|�}|�|j|t��Q|}|���Xyy�w)z2Iterate all live receivers listening for *sender*.N)	r%r
r(r4�copy�get�
isinstancer�_disconnect)rr-r8�idsr3r,�strongs       rrVzSignal.receivers_for~s�����
�>�>�)�&�1�I��D�O�O�+��o�o�f�-����	�0J�J���o�o�f�-�2�2�4��"�

���>�>�-�-�k�:���#���h�	�2�%�Z�F��~��(�(��f�=� �%�H���

�
�s�CC
c��|turt}nt|�}t|�}|j||�d|jvr6|j
jr|j
j|||��yyy)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``.

        r")r,r-N)rr4r
rir:r"r%r;)rr,r-r8r3s     rr<zSignal.disconnect�sv���S�=��I�)�&�1�I�'��1������i�0�
$�t�}�}�4��*�*�4�4��&�&�+�+�D�8�F�+�S�5�
5r c�`�|tk(ri|jj|d�r0|jj	�D]}|j|��|jj|d�y|j|j|�|j|j|�y)NF)r4r'�popr(�values�discardr%)rr3r8�buckets    rrizSignal._disconnect�s������� � �$�$�[�%�8�"�o�o�4�4�6�0�F��N�N�;�/�0��N�N���{�D�1��O�O�I�&�.�.�{�;����k�*�2�2�9�=r c�`�|jtt|j�t�y)z'Disconnect a receiver from all senders.N)ri�castrr3r4)rr=s  rr2zSignal._cleanup_receiver�s������l�L�,D�,D�E�v�Nr c��tt|j�}|tk7sJ�|jj|d�|jj|d�D] }|j|j|��"y)z'Disconnect all receivers from a sender.NrG)	rsrr8r4r)rnr(r'rp)rr>r8r3s    rr7zSignal._cleanup_sender�sq����z�';�';�<�	��F�"�"�"������y�$�/��?�?�.�.�y�"�=�	>�K����k�*�2�2�9�=�	>r c��|j|jfD]8}t|j��D]\}}|r�	|j	|d���:y)arPrune unused sender/receiver bookkeeping. Not threadsafe.

        Connecting & disconnecting leave behind a small amount of bookkeeping
        for the receiver and sender values. Typical workloads using Blinker,
        for example in most web apps, Flask, CLI scripts, etc., are not
        adversely affected by this bookkeeping.

        With a long-running Python process performing dynamic signal routing
        with high volume- e.g. connecting to function closures, "senders" are
        all unique object instances, and doing all of this over and over- you
        may see memory usage will grow due to extraneous bookkeeping. (An empty
        set() for each stale sender/receiver pair.)

        This method will prune that bookkeeping away, with the caveat that such
        pruning is not threadsafe. The risk is that cleanup of a fully
        disconnected receiver/sender pair occurs while another thread is
        connecting that same pair. If you are in the highly dynamic, unique
        receiver/sender situation that has lead you to this method, that
        failure mode is perhaps not a big deal for you.
        N)r(r'�list�itemsrn)r�mapping�_idrqs    r�_cleanup_bookkeepingzSignal._cleanup_bookkeeping�sQ��*����):�):�;�	+�G�#�G�M�M�O�4�
+���V���K�K��T�*�
+�	+r c���|jj�|jj�|jj�|jj�y)z4Throw away all signal state.  Useful for unit tests.N)r)�clearr%r(r'rs r�_clear_statezSignal._clear_state�sF����� � �"������������������!r )rFrrC)r�
str | NonerF�None)r,rr-�t.Anyr.�boolrFr)F)r-r�r.r�rFz$t.Callable[[T_callable], T_callable])r,�
t.Callabler-r�rF�t.Generator[None, None, None])rFr�)r,r�r-r�rFzt.ContextManager[None])r-r�rRzAsyncWrapperType | NonerYr�rF�list[tuple[t.Callable, t.Any]])r-r�r\zSyncWrapperType | NonerYr�rFr�)r-r�rFr�)r-r�rFr�)r-r�rFz3t.Generator[t.Callable[[t.Any], t.Any], None, None])r,r�r-r�rFr)r3rr8rrFr)r=r	rFr)r>r	rFr)rFr)�__name__�
__module__�__qualname__r$r�setr�__annotations__rrr"r*r@rHrrKrNrQr;r^rUrdrVr<rir2r7rzr}rGr rrr/s���!��C��I�y���	@��	@��C��C�.I�258�d�D�"�D�,1�D�?C�D�	�D�N+0����#'��	-��<�47�&�"�&�,1�&�	&�&��&�8�
"��
"�58�3�"�3�,1�3�	�3�037����0���	�

(��F15����.���	�

(��@�.<� ���	<��.@C�T�.>�O�>�+�4"r ra
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�"�eZdZdZddd�Zdd�Zy)�NamedSignalz%A named generic notification emitter.Nc�>�tj||�||_yrC)rr*�name)rr�rs   rr*zNamedSignal.__init__�s������c�"���	r c�V�tj|�}|dd�d|j�d�S)N���z; �>)r�__repr__r�)r�bases  rr�zNamedSignal.__repr__s-�����t�$���s��)��B�t�y�y�m�1�-�-r rC)r��strrr~rFr)rFr�)r�r�r�r$r*r�rGr rr�r��s��/��.r r�c��eZdZdZddd�Zy)�	Namespacez%A mapping of signal names to signals.Nc�h�	||S#t$r!|j|t||��}|cYSwxYw�z�Return the :class:`NamedSignal` *name*, creating it if required.

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

        ��KeyErrorr5r��rr�rr[s    r�signalzNamespace.signal	�<��	���:����	��_�_�T�;�t�S�+A�B�F��M�	����'1�1rC�r�r�rr~rFr��r�r�r�r$r�rGr rr�r�s
��/�
r r�c��eZdZdZddd�Zy)�
WeakNamespacea-A 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.

    .. versionadded:: 1.3

    Nc�h�	||S#t$r!|j|t||��}|cYSwxYwr�r�r�s    rr�zWeakNamespace.signal!r�r�rCr�r�rGr rr�r�s���
r r�).r$�
__future__r�typing�t�collectionsr�
contextlibr�inspectr�warningsr�weakrefr�blinker._utilitiesr	r
rrr
rr�
TYPE_CHECKING�typing_extensions�te�TypeVar�Callable�Anyrr�	ParamSpecr�	Awaitable�AsyncWrapperType�SyncWrapperTyperr4rsrrr��dictr�r�r�rGr r�<module>r�si���#��#�%�'��'�2�0�+�,�(�%�(��?�?�"�����<�q�z�z�#�q�u�u�*�/E�F�J���	�	�#��A�����S��A��z�z�1�:�:�a����Q��.?�#@�"A�1�:�:�a�QR�d�CS�"S�T���j�j�!�*�*�Q��T�"2�!3�Q�Z�Z��1�;�;�q�>�@Q�5R�!R�S�O��U�m��'���	
��	�v�v��r"�r"�j
����(.�&�.�
��
� �'��0
��	�	�r 

Zerion Mini Shell 1.0