Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/event/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/event/__pycache__/attr.cpython-311.pyc

�

�܋f6��d�dZddlmZddlmZddlZddlmZddlZddlm	Z	ddlm
Z
d	d
lmZd	dlmZd	dlm
Z
Gd
�dej��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZdS)a�Attribute implementation for _Dispatch classes.

The various listener targets for a particular event class are represented
as attributes, which refer to collections of listeners to be fired off.
These collections can exist at the class level as well as at the instance
level.  An event is fired off using code like this::

    some_object.dispatch.first_connect(arg1, arg2)

Above, ``some_object.dispatch`` would be an instance of ``_Dispatch`` and
``first_connect`` is typically an instance of ``_ListenerCollection``
if event listeners are present, or ``_EmptyListener`` if none are present.

The attribute mechanics here spend effort trying to ensure listener functions
are available with a minimum of function call overhead, that unnecessary
objects aren't created (i.e. many empty per-instance listener collections),
as well as that everything is garbage collectable when owning references are
lost.  Other features such as "propagation" of listener functions across
many ``_Dispatch`` instances, "joining" of multiple ``_Dispatch`` instances,
as well as support for subclass propagation (e.g. events assigned to
``Pool`` vs. ``QueuePool``) are all implemented here.

�)�absolute_import)�with_statementN)�chain�)�legacy)�registry�)�exc)�util)�	threadingc��eZdZdZd�ZdS)�
RefCollection)�refc�@�tj|tj��S�N)�weakrefrr�_collection_gced��selfs �L/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/event/attr.py�_memoized_attr_refz RefCollection._memoized_attr_ref1s���{�4��!:�;�;�;�N)�__name__�
__module__�__qualname__�	__slots__r�rrrr.s(�������I�<�<�<�<�<rrc�,�eZdZd�Zd�Zd�Zd�Zd�ZdS)�_empty_collectionc��dSrr�r�elements  r�appendz_empty_collection.append6����rc��dSrr)r�others  r�extendz_empty_collection.extend9r$rc��dSrrr!s  r�removez_empty_collection.remove<r$rc� �tg��Sr)�iterrs r�__iter__z_empty_collection.__iter__?s
���B�x�x�rc��dSrrrs r�clearz_empty_collection.clearBr$rN)rrrr#r'r)r,r.rrrrr5s_������
�
�
�
�
�
�
�
�
����
�
�
�
�
rrc�R�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
S)�_ClsLevelDispatchz2Class-level events on :class:`._Dispatch` classes.)�name�	arg_names�has_kw�legacy_signatures�	_clslevel�__weakref__c��|j|_tj|��}|jdd�|_t
|j��|_tttt|dg��d��������|_
tj|||��|_t#j��|_dS)Nr�_legacy_signaturesc��|dS�Nrr)�ss r�<lambda>z,_ClsLevelDispatch.__init__.<locals>.<lambda>Zs
���1��r)�key)rr1r�inspect_getfullargspec�argsr2�bool�varkwr3�list�reversed�sorted�getattrr4r�_augment_fn_docs�__doc__r�WeakKeyDictionaryr5)r�parent_dispatch_cls�fn�argspecs    r�__init__z_ClsLevelDispatch.__init__Rs����K��	��-�b�1�1�� ��a�b�b�)����7�=�)�)���!%����B� 4�b�9�9�~�~����
�
�"
�"
����,�T�3F��K�K��
� �2�4�4����rc��|r|�|��}|jr>	tj|d���}t	j|||��}n#t$rYnwxYw|S)NT)�no_self)�_wrap_fn_for_kwr4r�get_callable_argspecr�_wrap_fn_for_legacy�	TypeError)rrJ�namedrKs    r�_adjust_fn_specz!_ClsLevelDispatch._adjust_fn_specbs����	*��%�%�b�)�)�B��!�	C�
C��3�B��E�E�E���/��b�'�B�B�����
�
�
���
�����	s�A
�
A�Ac������fd�}|S)Nc���tt�j|����}|�|���di|��S)Nr)�dict�zipr2�update)r?�kw�argdictrJrs   ��r�wrap_kwz2_ClsLevelDispatch._wrap_fn_for_kw.<locals>.wrap_kwos@����3�t�~�t�4�4�5�5�G��N�N�2�����2�=�=��=�=� rr)rrJr\s`` rrOz!_ClsLevelDispatch._wrap_fn_for_kwns)����	!�	!�	!�	!�	!�	!�
�rc��|j}t|t��s
Jd���t|dd��st	jd|z���|g}|r�|�d��}|�|�����||ur||j	vr|�
|��nC||j	vr|�|��|j	|�|j
��|��tj||��dS�Nz*Class-level Event targets must be classes.�_sa_propagate_class_eventsTz.Can't assign an event directly to the %s classr)�dispatch_target�
isinstance�typerEr
�InvalidRequestError�popr'�__subclasses__r5�update_subclass�_assign_cls_collection�
appendleft�
_listen_fnr�_stored_in_collection�r�	event_key�	propagate�target�stack�clss      r�insertz_ClsLevelDispatch.insertvs>���*����D�
�
�	8�	8�7�	8�	8�
��v�;�T�B�B�	��)�@�6�I���
�����	E��)�)�A�,�,�C��L�L��+�+�-�-�.�.�.��&� � �S���%>�%>��$�$�S�)�)�)�)��d�n�,�,��/�/��4�4�4���s�#�.�.�y�/C�D�D�D��	E�	�&�y�$�7�7�7�7�7rc��|j}t|t��s
Jd���t|dd��st	jd|z���|g}|r�|�d��}|�|�����||ur||j	vr|�
|��nC||j	vr|�|��|j	|�|j
��|��tj||��dSr^)r`rarbrEr
rcrdr'rer5rfrgr#rirrjrks      rr#z_ClsLevelDispatch.append�s>���*����D�
�
�	8�	8�7�	8�	8�
��v�;�T�B�B�	��)�@�6�I���
�����	A��)�)�A�,�,�C��L�L��+�+�-�-�.�.�.��&� � �S���%>�%>��$�$�S�)�)�)�)��d�n�,�,��/�/��4�4�4���s�#�*�*�9�+?�@�@�@��	A�	�&�y�$�7�7�7�7�7rc��t|dd��rtj��|j|<dSt	��|j|<dS)Nr_T)rE�collections�dequer5r)rrns  rrgz(_ClsLevelDispatch._assign_cls_collection�sJ���6�7��>�>�	9�%0�%6�%8�%8�D�N�6�"�"�"�%6�%8�%8�D�N�6�"�"�"rc����||jvr|�|��|j|�|jdd�D]7}||jvr,���fd�|j|D�����8dS)Nrc���g|]}|�v�|��	Srr)�.0rJ�clslevels  �r�
<listcomp>z5_ClsLevelDispatch.update_subclass.<locals>.<listcomp>�s#���L�L�L�B��8�9K�9K�R�9K�9K�9Kr)r5rg�__mro__r')rrnrprys   @rrfz!_ClsLevelDispatch.update_subclass�s�������'�'��'�'��/�/�/��>�&�)���>�!�"�"�%�	�	�C��d�n�$�$����L�L�L�L�$�.��"5�L�L�L�����	�	rc� �|j}|g}|rl|�d��}|�|�����||jvr%|j|�|j��|�ltj||��dSr:)	r`rdr'rer5r)rir�_removed_from_collection)rrlrnrorps     rr)z_ClsLevelDispatch.remove�s����*������	A��)�)�A�,�,�C��L�L��+�+�-�-�.�.�.��d�n�$�$���s�#�*�*�9�+?�@�@�@�	�	A�
	�)�)�T�:�:�:�:�:rc���t��}|j���D]+}|�|��|����,tj||��dS)zClear all class level listenersN)�setr5�valuesrYr.r�_clear)r�to_clear�
dispatchers   rr.z_ClsLevelDispatch.clear�si���5�5���.�/�/�1�1�	�	�J��O�O�J�'�'�'�����������h�'�'�'�'�'rc��|S)z�Return an event collection which can be modified.

        For _ClsLevelDispatch at the class level of
        a dispatcher, this returns self.

        r�r�objs  r�
for_modifyz_ClsLevelDispatch.for_modify��	���rN)rrrrGrrLrTrOrqr#rgrfr)r.r�rrrr0r0Fs�������<�<��I�5�5�5� 
�
�
����8�8�8�*8�8�8�*9�9�9����;�;�;�(�(�(�����rr0c��eZdZdZd�ZdS)�_InstanceLevelDispatchrc�8�|j�||��Sr)�parentrT�rrJrSs   rrTz&_InstanceLevelDispatch._adjust_fn_spec�s���{�*�*�2�u�5�5�5rN)rrrrrTrrrr�r��s(�������I�6�6�6�6�6rr�c�t�eZdZdZe��ZdZdZd�Zd�Z	d�Z
e
xZxZxZ
xZxZZd�Zd�Zd	�Zd
�ZeZdS)�_EmptyListenerz�Serves as a proxy interface to the events
    served by a _ClsLevelDispatch, when there are no
    instance-level events present.

    Is replaced by _ListenerCollection when instance-level
    events are added.

    r)r��parent_listenersr1c��||jvr|�|��||_|j||_|j|_dSr)r5rfr�r�r1�rr��
target_clss   rrLz_EmptyListener.__init__�sH���V�-�-�-��"�"�:�.�.�.���� &� 0�� <����K��	�	�	rc���t|j|j��}t||j��|urt||j|��n*t
t||j��t��sJ�|S)z�Return an event collection which can be modified.

        For _EmptyListener at the instance level of
        a dispatcher, this generates a new
        _ListenerCollection, applies it to the instance,
        and returns it.

        )�_ListenerCollectionr��
_instance_clsrEr1�setattrra�_JoinedListener)rr��results   rr�z_EmptyListener.for_modify�sm��%�T�[�#�2C�D�D���3��	�"�"�d�*�*��C���F�+�+�+�+��g�c�4�9�5�5��G�G�G�G�G��
rc� �td���)Nzneed to call for_modify()��NotImplementedError�rr?rZs   r�
_needs_modifyz_EmptyListener._needs_modify�s��!�"=�>�>�>rc�*�|jD]
}||i|���dS�zExecute this event.N)r��rr?rZrJs    r�__call__z_EmptyListener.__call__s3���'�	�	�B��B��O��O�O�O�O�	�	rc�*�t|j��Sr)�lenr�rs r�__len__z_EmptyListener.__len__s���4�(�)�)�)rc�*�t|j��Sr)r+r�rs rr,z_EmptyListener.__iter__
����D�)�*�*�*rc�*�t|j��Sr)r@r�rs r�__bool__z_EmptyListener.__bool__
r�rN)rrrrG�	frozensetrm�	listenersrrLr�r��	exec_once�exec_once_unless_exceptionrqr#r)r.r�r�r,r��__nonzero__rrrr�r��s����������	���I��I�4�I� � � ���� ?�?�?�
,9�9�I�9�"�9��9��9� �5����*�*�*�+�+�+�+�+�+��K�K�Krr�c�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZeZd
S)�_CompoundListener��_exec_once_mutex�
_exec_oncec�(�tj��Sr)r�Lockrs r�_memoized_attr__exec_once_mutexz1_CompoundListener._memoized_attr__exec_once_mutexs���~���rc��|j5|js1	||i|��d}n#d}�xYw	|r|sd|_n#|r|sd|_wxYwddd��dS#1swxYwYdS)NFTr�)r�retry_on_exceptionr?rZ�	exceptions     r�_exec_once_implz!_CompoundListener._exec_once_impls���
�
"�
	/�
	/��?�	
/�/��D�$�%�"�%�%�%� %�I�I��� $�I������
%�/�,>�/�*.�����%�/�,>�/�*.���.�.�.�.�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/�
	/����
	/�
	/�
	/�
	/�
	/�
	/s/�A�
�1�!�1�A�
>�A�A�Ac�:�|js|jdg|�Ri|��dSdS)z]Execute this event, but only if it has not been
        executed already for this collection.FN�r�r�r�s   rr�z_CompoundListener.exec_once&sA����	5� �D� ��4��4�4�4��4�4�4�4�4�	5�	5rc�:�|js|jdg|�Ri|��dSdS)atExecute this event, but only if it has not been
        executed already for this collection, or was called
        by a previous exec_once_unless_exception call and
        raised an exception.

        If exec_once was already called, then this method will never run
        the callable regardless of whether it raised or not.

        .. versionadded:: 1.3.8

        TNr�r�s   rr�z,_CompoundListener.exec_once_unless_exception-sA����	4� �D� ��3��3�3�3��3�3�3�3�3�	4�	4rc�N�|jD]
}||i|���|jD]
}||i|���dSr�)r�r�r�s    rr�z_CompoundListener.__call__<sW���'�	�	�B��B��O��O�O�O�O��.�	�	�B��B��O��O�O�O�O�	�	rc�T�t|j��t|j��zSr)r�r�r�rs rr�z_CompoundListener.__len__Ds"���4�(�)�)�C���,?�,?�?�?rc�6�t|j|j��Sr)rr�r�rs rr,z_CompoundListener.__iter__Gs���T�*�D�N�;�;�;rc�8�t|jp|j��Sr)r@r�r�rs rr�z_CompoundListener.__bool__Js���D�N�;�d�&;�<�<�<rN)
rrrrr�r�r�r�r�r�r,r�r�rrrr�r�s�������0�I� � � �/�/�/�5�5�5�
4�
4�
4����@�@�@�<�<�<�=�=�=��K�K�Krr�c�B�eZdZdZdZd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�ZdS)
r�z�Instance-level attributes on instances of :class:`._Dispatch`.

    Represents a collection of listeners.

    As of 0.7.9, _ListenerCollection is only first
    created via the _EmptyListener.for_modify() method.

    )r�r�r1r�rmr6c���||jvr|�|��d|_|j||_||_|j|_t
j��|_t��|_
dS�NF)r5rfr�r�r�r1rtrur�rrmr�s   rrLz_ListenerCollection.__init__csj���V�-�-�-��"�"�:�.�.�.���� &� 0�� <�������K��	�$�*�,�,���������rc��|S)z�Return an event collection which can be modified.

        For _ListenerCollection at the instance level of
        a dispatcher, this returns self.

        rr�s  rr�z_ListenerCollection.for_modifymr�rTc�*�����j}t|����j�|j�����fd�|jD��}|�|��|j�|��}t
j�||��dS)zIPopulate from the listeners in another :class:`_Dispatch`
        object.c�2��g|]}|�vr�r	|�jv�|��Sr)rm)rx�l�existing_listener_set�only_propagaters  ���rrzz/_ListenerCollection._update.<locals>.<listcomp>}sF���
�
�
���-�-�-�"�.��D�N�"�"�	
�#�"�"rN)r�rrmrYr'�unionr�_stored_in_collection_multi)rr&r��existing_listeners�other_listeners�to_associater�s` `   @r�_updatez_ListenerCollection._updatevs������"�^�� #�$6� 7� 7������e�o�.�.�.�
�
�
�
�
�
��_�
�
�
��	�!�!�/�2�2�2���,�,�_�=�=���,�T�5�,�G�G�G�G�Grc��|�||j��r#|r#|j�|j��dSdSdSr)�prepend_to_listr�rm�addri�rrlrms   rrqz_ListenerCollection.insert�sW���$�$�T�4�>�:�:�	9��
9���"�"�9�#7�8�8�8�8�8�	9�	9�
9�
9rc��|�||j��r#|r#|j�|j��dSdSdSr)�append_to_listr�rmr�rir�s   rr#z_ListenerCollection.append�sW���#�#�D�$�.�9�9�	9��
9���"�"�9�#7�8�8�8�8�8�	9�	9�
9�
9rc��|j�|j��|j�|j��tj||��dSr)r�r)rirm�discardrr}�rrls  rr)z_ListenerCollection.remove�sM������i�2�3�3�3�����y�3�4�4�4��)�)�T�:�:�:�:�:rc��tj||j��|j���|j���dSr)rr�r�rmr.rs rr.z_ListenerCollection.clear�sD�����d�n�-�-�-����������������rN)T)rrrrGrrLr�r�rqr#r)r.rrrr�r�Ps����������I�������H�H�H�H�(9�9�9�
9�9�9�
;�;�;�
����rr�c�R�eZdZdZd�Zed���Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
S)r�)r�r1�localr�c�V�d|_||_||_||_|j|_dSr�)r�r�r1r�r�)rr�r1r�s    rrLz_JoinedListener.__init__�s.����������	���
� $�
����rc�6�t|j|j��Sr)rEr�r1rs rr�z_JoinedListener.listeners�s���t�{�D�I�.�.�.rc�8�|j�||��Sr)r�rTr�s   rrTz_JoinedListener._adjust_fn_spec�s���z�)�)�"�e�4�4�4rc�R�|j�|��x|_|_|Sr)r�r�r�r�s  rr�z_JoinedListener.for_modify�s&��-1�Z�-B�-B�3�-G�-G�G��
�T�*��rc�<�|j�||��dSr)r�rqr�s   rrqz_JoinedListener.insert�� ���
���)�Y�/�/�/�/�/rc�<�|j�||��dSr)r�r#r�s   rr#z_JoinedListener.append�r�rc�:�|j�|��dSr)r�r)r�s  rr)z_JoinedListener.remove�s���
���)�$�$�$�$�$rc��t���rr�rs rr.z_JoinedListener.clear�s��!�#�#�#rN)
rrrrrL�propertyr�rTr�rqr#r)r.rrrr�r��s�������=�I�+�+�+��/�/��X�/�5�5�5����0�0�0�0�0�0�%�%�%�$�$�$�$�$rr�)rG�
__future__rrrt�	itertoolsrr�rrr
rr�
MemoizedSlotsr�objectrr0r�r�r�r�r�rrr�<module>r�s+����0'�&�&�&�&�&�%�%�%�%�%�%���������������������������������������������<�<�<�<�<�D�&�<�<�<�
�
�
�
�
��
�
�
�"D�D�D�D�D�
�D�D�D�N6�6�6�6�6�]�6�6�6�<�<�<�<�<�+�<�<�<�~:�:�:�:�:�.�:�:�:�zL�L�L�L�L�+�L�L�L�^$�$�$�$�$�'�$�$�$�$�$r

Hacked By AnonymousFox1.0, Coded By AnonymousFox