AlkantarClanX12

Your IP : 3.137.181.69


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/blinker/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/blinker/__pycache__/base.cpython-311.pyc

�

e��f�?���dZddlmZddlmZddlmZmZmZm	Z	m
Z
mZmZed��Z
de
_dZGd�de��Zed	��ZGd
�de��ZGd�d
e��ZGd�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��eZdZdZeZed���Zed���Zdd�Zedfd�Z	dd	�Z
eefd
���Zefd�Z
d�Zd
�Zd�Zefd�Zd�Zd�Zd�Zd�Zd�ZdS)�SignalzA notification emitter.c�"�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 �l/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/blinker/base.py�receiver_connectedzSignal.receiver_connected%s���>�?�?�?�?�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_disconnected1s��,�A�B�B�B�BrNc��|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)rrs  r�__init__zSignal.__init__IsI���	��D�L����'��,�,���%�c�*�*�������rTc�Z�t|��}|rt||j��}||_n|}|turt
}nt|��}|j�||��|j|�	|��|j
|�	|��~|turS||jvrJ	t||j��}||_
|j�||��~n#t$rYnwxYwd|jvrH|jjr<	|j�||||���n#|�||���xYwt jrE|t ur<	t �||||���n#|�||���xYw|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�weak)�receiver_arg�
sender_arg�weak_arg)rr
�_cleanup_receiver�receiver_idr�ANY_IDr�
setdefaultr�addrr �_cleanup_sender�	sender_id�	TypeError�__dict__r�send�
disconnect)rr#r$r%r*�receiver_refr/�
sender_refs        r�connectzSignal.connect\s��&(��1�1���	$�$�X�t�/E�F�F�L�'2�L�$�$�#�L��S�=�=��I�I�)�&�1�1�I���!�!�+�|�<�<�<���	�"�&�&�{�3�3�3���+�&�*�*�9�5�5�5�������$�2D�!D�!D�
�&�v�t�/C�D�D�
�'0�
�$��"�-�-�i��D�D�D��J��	�
�
�
���
����
!�D�M�1�1��#�-�
2�
��'�,�,�T�6>�4:�26�-�8�8�8�8��
�����&�1�1�1������'�	�D�8J�,J�,J�
�"�'�'��5=�39�15�(�7�7�7�7��
�����&�1�1�1������s*�C9�9
D�D�D>�>E�0F�F(Fc��������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�6����|����|S�N)r6)�fnrr$r%s ���r�	decoratorz%Signal.connect_via.<locals>.decorator�s����L�L��V�T�*�*�*��Ir�)rr$r%r;s``` r�connect_viazSignal.connect_via�s0�����*	�	�	�	�	�	�	��rc#�K�|�||d���	dV�|�|��dS#|�|���xYw)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

        F)r$r%N)r6r3�rr#r$s   r�connected_tozSignal.connected_to�sf����8	
���X�f�5��9�9�9�	&��J�J�J�

�O�O�H�%�%�%�%�%��		��O�O�H�%�%�%����s	�7�Ac�X�tdt��|�||��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�DeprecationWarningr@r?s   r�temporarily_connected_tozSignal.temporarily_connected_to�s6��	
�)�
�	!�	!�	!�� � ��6�2�2�2rc����t���dkrd�n:t���dkrtdt���z����d�|jsgS��fd�|����D��S)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 givenc�&��g|]
}||�fi���f��Sr<r<)�.0r#�kwargsr$s  ��r�
<listcomp>zSignal.send.<locals>.<listcomp>
sF���@�@�@� ��x�x��9�9�&�9�9�:�@�@�@r)�lenr0r�
receivers_for)rr$rHs ``rr2zSignal.send�s������v�;�;�!����F�F�
��[�[�1�_�_��'�),�V���5�6�6�
6��A�Y�F��~�	@��I�@�@�@�@�@�$(�$6�$6�v�$>�$>�@�@�@�
@rc�~�|jsdS|jtrdS|turdSt	|��|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)rrr+rr)rr$s  r�has_receivers_forzSignal.has_receivers_for
sJ���~�	��5��?�6�"�	��4��S�=�=��5� ��(�(�D�O�;�;rc#�K�|jr�t|��}||jvr!|jt|j|z}n$|jt���}|D]d}|j�|��}|��t
|t��r*|��}|�|�|t���\|}|V��cdSdS)z2Iterate all live receivers listening for *sender*.N)	rrrr+�copy�get�
isinstancer�_disconnect)rr$r/�idsr*r#�strongs       rrKzSignal.receivers_fors������>�	�)�&�1�1�I��D�O�+�+���v�.���y�1�2����o�f�-�2�2�4�4��"�

�

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

�

rc��|turt}nt|��}t|��}|�||��d|jvr+|jjr!|j�|||���dSdSdS)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)rr+rrRr1rrr2)rr#r$r/r*s     rr3zSignal.disconnect3s����S�=�=��I�I�)�&�1�1�I�'��1�1������i�0�0�0�#�t�}�4�4��&�0�
5��&�+�+�D�5=�39�
,�
;�
;�
;�
;�
;�
5�4�4�4rc�n�|tkri|j�|d��r1|j���D]}|�|���|j�|d��dS|j|�|��|j|�|��dS)NF)r+r�popr�values�discardr)rr*r/�buckets    rrRzSignal._disconnectIs�������� �$�$�[�%�8�8�
0�"�o�4�4�6�6�0�0�F��N�N�;�/�/�/�/��N���{�D�1�1�1�1�1��O�I�&�.�.�{�;�;�;���k�*�2�2�9�=�=�=�=�=rc�F�|�|jt��dS)z'Disconnect a receiver from all senders.N)rRr*r+)rr4s  rr)zSignal._cleanup_receiverSs!������1�6�:�:�:�:�:rc���|j}|tksJ�|j�|d��|j�|d��D]"}|j|�|���#dS)z'Disconnect all receivers from a sender.Nr<)r/r+r rWrrrY)rr5r/r*s    rr.zSignal._cleanup_senderWs~���(�	��F�"�"�"�"�����y�$�/�/�/��?�.�.�y�"�=�=�	>�	>�K���k�*�2�2�9�=�=�=�=�	>�	>rc��|j|jfD]A}t|�����D]\}}|s|�|d����BdS)anPrune unused sender/receiver bookeeping. Not threadsafe.

        Connecting & disconnecting leave behind a small amount of bookeeping
        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 bookeeping. (An empty
        set() for each stale sender/receiver pair.)

        This method will prune that bookeeping 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)rr�list�itemsrW)r�mapping�_idrZs    r�_cleanup_bookkeepingzSignal._cleanup_bookkeeping_sl��*���):�;�	+�	+�G�#�G�M�M�O�O�4�4�
+�
+���V��+��K�K��T�*�*�*��
+�	+�	+rc���|j���|j���|j���|j���dS)z4Throw away all signal state.  Useful for unit tests.N)r �clearrrrrs r�_clear_statezSignal._clear_stateysZ���� � �"�"�"�������������������!�!�!�!�!rr9)F)�__name__�
__module__�__qualname__rrr	rrr!r6r=rr@rCr2rMrKr3rRr)r.rbrer<rrrrst������!�!��C��	@�	@��]�	@��C�C��]�C�. � � � �&(+��B�B�B�B�H����4�,/�"&�"&�"&��^�"&�H9<�3�3�3�3�$@�@�@�8<�<�<� ���,+.�;�;�;�;�,>�>�>�;�;�;�>�>�>�+�+�+�4"�"�"�"�"rra
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� �eZdZdZdd�Zd�ZdS)�NamedSignalz%A named generic notification emitter.Nc�J�t�||��||_dSr9)rr!�name�rrlrs   rr!zNamedSignal.__init__�s#������c�"�"�"���	�	�	rc�`�t�|��}|dd��d|j�d�S)N���z; �>)r�__repr__rl)r�bases  rrqzNamedSignal.__repr__�s0�����t�$�$�� ��"��I�I�I�t�y�y�y�1�1rr9)rfrgrhrr!rqr<rrrjrj�s=������/�/�����2�2�2�2�2rrjc��eZdZdZdd�ZdS)�	Namespacez%A mapping of signal names to signals.Nc�|�	||S#t$r'|�|t||����cYSwxYw�z�Return the :class:`NamedSignal` *name*, creating it if required.

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

        ��KeyErrorr,rjrms   r�signalzNamespace.signal��U��	A���:����	A�	A�	A��?�?�4��T�3�)?�)?�@�@�@�@�@�	A�����
�.;�;r9�rfrgrhrryr<rrrtrt�s4������/�/�	A�	A�	A�	A�	A�	Arrtc��eZdZdZdd�ZdS)�
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�|�	||S#t$r'|�|t||����cYSwxYwrvrwrms   rryzWeakNamespace.signal�rzr{r9r|r<rrr~r~�s8��������	A�	A�	A�	A�	A�	Arr~N)r�warningsr�weakrefr�blinker._utilitiesrrrrr	r
rrr+�objectrrrj�dictrtr~ryr<rr�<module>r�s�����������'�'�'�'�'�'�������������������
�f�U�m�m��'���	
��`"�`"�`"�`"�`"�V�`"�`"�`"�F�V�����$2�2�2�2�2�&�2�2�2�A�A�A�A�A��A�A�A�A�A�A�A�A�'�A�A�A�.
����	���r