%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�]ue�#���dZddlZddlZddlZddlZej
d�Zej
d�Zdd�ZGd�d�Z	y)	z-Refactored 'safe reference from dispatcher.py�N�__self__�__func__c��	t|�}|�2t|d�st|d�sJd|�d���t||��}|Sy#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.
    N�im_funcrzsafe_ref target z@ has im_self, but no im_func, don't know how to create reference)�target�	on_delete)�get_self�hasattr�BoundMethodWeakref�AttributeError�callable�weakref�ref)rr�im_self�	references    �2/usr/lib/python3/dist-packages/blinker/_saferef.py�safe_refr.s�����6�"�����6�9�-����1L�
�"�6�*�-5�5�
�L�+�&�I�N�I�����
�'��I���;�;�v�y�1�1��;�;�v�&�&�	'�s�A�*B�.B�Bc���eZdZdZej
�Zd
�fd�	Zd
d�Ze	d��Z
d�ZeZd�Z
d�Zd�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.
    c���|j|�}|jj|�}|�|jj	|�|St
�|�|�}||j|<|j||g|��i|��|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�super�__new__�__init__)	�clsrr�	arguments�named�key�current�base�	__class__s	        �rrzBoundMethodWeakref.__new__qs��������'���$�$�(�(��-�����$�$�+�+�I�6��N��7�?�3�'�D�&*�C���s�#��D�M�M�&�)�A�i�A�5�A��K�c�6�|fd�}|g|_|j|�|_t|�}t	|�}tj||�|_tj||�|_t|�|_
t|j�|_y)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=|D]}	t|�r||��y#t$rY�'wxYw#t$rS	tj�n:#t$r.tj�d}td|�d|�d|���YnwxYwY��wxYw)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�.�G��%�%�a�(�
��N�N�1�1�$�(�(�;�$�
�����)� ����
���
��
��!���!�+�+�-��)���L�L�N�1�-���7��v�>0�08�z��A�3�@�����sG�!A�A,�	A)�(A)�,	C�6B�
C�4C�?C�C�C�CN)
rrr!r	�get_funcrr�	weak_self�	weak_func�str�	self_name�__name__�	func_name)r1rrr5rrs      rrzBoundMethodWeakref.__init__�s��"#�	�,"+�����%�%�f�-����6�"���6�"�� ���W�f�5��� ���W�f�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.
        )�idr	r6)rrs  rrz BoundMethodWeakref.calculate_key�s#���8�F�#�$�b��&�)9�&:�;�;r%c�x�dj|jj|j|j�S)z-Give a friendly representation of the object.z	{}({}.{}))�formatr$r;r:r<�r1s r�__str__zBoundMethodWeakref.__str__�s0���!�!��N�N�#�#��N�N��N�N�
�	
r%c�D�t|j|jf�S�N)�hashr:r!rAs r�__hash__zBoundMethodWeakref.__hash__�s���T�^�^�T�X�X�.�/�/r%c��|�duS)z'Whether we are still a valid reference.N�rAs r�__nonzero__zBoundMethodWeakref.__nonzero__�s���v�T�!�!r%c���t||j�s)tj|jt	|��Stj|j
|j
�S)zCompare with another reference.)�
isinstancer$�operator�eq�typer!)r1�others  r�__eq__zBoundMethodWeakref.__eq__�sB���%����0��;�;�t�~�~�t�E�{�;�;��{�{�4�8�8�U�Y�Y�/�/r%c�n�|j�}|�#|j�}|�|j|�Sy)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)r7r8�__get__)r1rr3s   r�__call__zBoundMethodWeakref.__call__�s<�����!�����~�~�'�H��#��'�'��/�/�r%rD)r;�
__module__�__qualname__�__doc__r�WeakValueDictionaryrrr�classmethodrrB�__repr__rFrIrPrS�
__classcell__)r$s@rrrMsZ����B1�W�0�0�2�N��,./�`�<��<�
��H�0�"�0�r%rrD)
rVrLr-r+r�
attrgetterr	r6rrrHr%r�<module>r\sN��F4��
����8���z�*���8���z�*���>Y�Yr%

Zerion Mini Shell 1.0