Your IP : 18.222.98.91


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

�

N�Dg$��
�dZddlZddlZddlZddlZ	en#e$rd�ZYnwxYwejdkr!ejd��Z	ejd��Z
n ejd��Z	ejd��Z
dd	�ZGd
�de��Z
dS)
z-Refactored 'safe reference from dispatcher.py�Nc�"�t|d��S)N�__call__)�hasattr)�objects �p/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/blinker/_saferef.py�callabler.s���v�z�*�*�*�)��im_self�im_func�__self__�__func__c�>�	t|��}|�@t|d��st|d��s
Jd|z���t||���}|SdS#t$r=t	|��rtj||��cYStj|��cYSwxYw)a�Return a *safe* weak reference to a callable target.

    - ``target``: The object to be weakly referenced, if it's a bound
      method reference, will create a BoundMethodWeakref, otherwise
      creates a simple weakref.

    - ``on_delete``: If provided, will have a hard reference stored to
      the callable to be called after the safe reference goes out of
      scope with the reference object, (either a weakref or a
      BoundMethodWeakref) as argument.
    NrrzRsafe_ref target %r has im_self, but no im_func, don't know how to create reference)�target�	on_delete)�get_selfr�BoundMethodWeakref�AttributeErrorr�weakref�ref)rrr�	references    r�safe_refr:s�����6�"�"�����6�9�-�-�
?����1L�1L�
?�
?�5�7=�>�
?�
?�L�+�&�I�N�N�N�I������
�'�'�'��I���	'��;�v�y�1�1�1�1�1��;�v�&�&�&�&�&�	'���s�A�.B�B�Bc���eZdZdZej��Zd
�fd�	Zd
d�Zd�Z	e
e	��Z	d�ZeZd�Z
d�Zd	�Z�xZS)ra�'Safe' and reusable weak references to instance methods.

    BoundMethodWeakref objects provide a mechanism for referencing a
    bound method without requiring that the method object itself
    (which is normally a transient object) is kept alive.  Instead,
    the BoundMethodWeakref object keeps weak references to both the
    object and the function which together define the instance method.

    Attributes:

    - ``key``: The identity key for the reference, calculated by the
      class's calculate_key method applied to the target instance method.

    - ``deletion_methods``: Sequence of callable objects taking single
      argument, a reference to this object which will be called when
      *either* the target object or target function is garbage
      collected (i.e. when this object becomes invalid).  These are
      specified as the on_delete parameters of safe_ref calls.

    - ``weak_self``: Weak reference to the target object.

    - ``weak_func``: Weak reference to the target function.

    Class Attributes:

    - ``_all_instances``: Class attribute pointing to all live
      BoundMethodWeakref objects indexed by the class's
      calculate_key(target) method applied to the target objects.
      This weak value dictionary is used to short-circuit creation so
      that multiple references to the same (object, function) pair
      produce the same BoundMethodWeakref instance.
    Nc�*��|�|��}|j�|��}|�|j�|��|Stt|���|��}||j|<|j||g|�Ri|��|S)a�Create new instance or return current instance.

        Basically this method of construction allows us to
        short-circuit creation of references to already- referenced
        instance methods.  The key corresponding to the target is
        calculated, and if there is already an existing reference,
        that is returned, with its deletion_methods attribute updated.
        Otherwise the new instance is created and registered in the
        table of already-referenced methods.
        )	�
calculate_key�_all_instances�get�deletion_methods�append�superr�__new__�__init__)	�clsrr�	arguments�named�key�current�base�	__class__s	        �rr!zBoundMethodWeakref.__new__|s��������'�'���$�(�(��-�-�����$�+�+�I�6�6�6��N��+�S�1�1�9�9�#�>�>�D�&*�C��s�#��D�M�&�)�A�i�A�A�A�5�A�A�A��Kr	c�R�|fd�}|g|_|�|��|_t|��}t	|��}tj||��|_tj||��|_t|��|_
t|j��|_dS)a�Return a weak-reference-like instance for a bound method.

        - ``target``: The instance-method target for the weak reference,
          must have im_self and im_func attributes and be
          reconstructable via the following, which is true of built-in
          instance methods::

            target.im_func.__get__( target.im_self )

        - ``on_delete``: Optional callback which will be called when
          this weak reference ceases to be valid (i.e. either the
          object or the function is garbage collected).  Should take a
          single argument, which will be passed a pointer to this
          object.
        c��|jdd�}|jdd�=	|jj|j=n#t$rYnwxYw|D]�}	t|��r||���#t$rY	tj��nA#t$r4tj��d}td|�d|�d|����YnwxYwY��wxYwdS)z=Set self.isDead to True when method or instance is destroyed.N�zException during saferef z cleanup function z: )
rr)rr&�KeyErrorr�	Exception�	traceback�	print_excr�sys�exc_info�print)�weak�self�methods�function�es     r�removez+BoundMethodWeakref.__init__.<locals>.remove�s<���+�A�A�A�.�G��%�a�a�a�(�
��N�1�$�(�;�;���
�
�
���
����#�

P�

P��	P���)�)�'� �������� �P�P�P�P�!�+�-�-�-�-��)�P�P�P��L�N�N�1�-����<@�D�D�(�(�(�A�A� O�P�P�P�P�P�P������P����	

P�

PsB�.�
;�;�A�
C�)A=�<C�=;B;�8C�:B;�;C�CN)
rrr&r�get_funcrr�	weak_self�	weak_func�str�	self_name�__name__�	func_name)r5rrr9rrs      rr"zBoundMethodWeakref.__init__�s��� #�	P�	P�	P�	P�&"+�����%�%�f�-�-����6�"�"���6�"�"�� ��W�f�5�5��� ��W�f�5�5����W������W�-�.�.����r	c�r�tt|����tt|����fS)z�Calculate the reference key for this reference.

        Currently this is a two-tuple of the id()'s of the target
        object and the target function respectively.
        )�idrr:)r#rs  rrz BoundMethodWeakref.calculate_key�s/���8�F�#�#�$�$�b��&�)9�)9�&:�&:�;�;r	c�@�|jj�d|j�d|j�d�S)z-Give a friendly representation of the object.�(�.�))r)r?r>r@�r5s r�__str__zBoundMethodWeakref.__str__�s.��
�N�#�#�#��N�N�N��N�N�N��	r	c��|��duS)z'Whether we are still a valid reference.N�rGs r�__nonzero__zBoundMethodWeakref.__nonzero__�s���t�v�v�T�!�!r	c��t||j��s"t|jt|����St|j|j��S)zCompare with another reference.)�
isinstancer)�cmp�typer&)r5�others  r�__cmp__zBoundMethodWeakref.__cmp__�sB���%���0�0�	4��t�~�t�E�{�{�3�3�3��4�8�U�Y�'�'�'r	c��|���}|�+|���}|�|�|��SdS)a?Return a strong reference to the bound method.

        If the target cannot be retrieved, then will return None,
        otherwise returns a bound instance method for our object and
        function.

        Note: You may call this method any number of times, as it does
        not invalidate the reference.
        N)r;r<�__get__)r5rr7s   rrzBoundMethodWeakref.__call__�sG�����!�!�����~�~�'�'�H��#��'�'��/�/�/��tr	�N)r?�
__module__�__qualname__�__doc__r�WeakValueDictionaryrr!r"r�classmethodrH�__repr__rKrQr�
__classcell__)r)s@rrrXs����������B1�W�0�2�2�N�������,*/�*/�*/�*/�X<�<�<� �K�
�.�.�M�����H�"�"�"�(�(�(�������r	rrT)rW�operatorr1r/rr�	NameError�version_info�
attrgetterrr:rrrrJr	r�<module>r`s!��F4�3�����
�
�
�
���������+��H�H���+�+�+�+�+�+�+�+�+����
��d���"�x�"�9�-�-�H�"�x�"�9�-�-�H�H�"�x�"�:�.�.�H�"�x�"�:�.�.�H�����<R�R�R�R�R��R�R�R�R�Rs��"�"

?>