PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/sqlalchemy/orm/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/sqlalchemy/orm/__pycache__/clsregistry.cpython-312.pyc

�

���g6F���UdZddlmZddlZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZddlm
Z
dd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlmZddl"m#Z#dd l$m%Z%erdd!l&m'Z'dd"l"m(Z(dd#l"m)Z)ed$e�%�Z*e
e+ee,d&ffZ-e.�Z/d'e0d(<								d>d)�Z1								d?d*�Z2								d@d+�Z3Gd,�d&�Z4Gd-�d.e4�Z5Gd/�d0e4�Z6Gd1�d2�Z7Gd3�d4�Z8e!jre8�d5��Gd6�d7�Z:dAd8�Z;Gd9�d:�Z<da=d;e0d<<dBd=�Z>y)Cz�Routines to handle the string class registry used by declarative.

This system allows specification of classes and expressions used in
:func:`_orm.relationship` using strings.

�)�annotationsN)�Any)�Callable)�cast)�Dict)�	Generator)�Iterable)�List)�Mapping)�MutableMapping)�NoReturn)�Optional)�Set)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�
attributes)�
interfaces)�SynonymProperty)�ColumnProperty)�class_mapper�)�exc)�
inspection)�util)�_get_table_key)�CallableReference)�RelationshipProperty)�MetaData)�Table�_T)�bound�ClsRegistryTokenzSet[ClsRegistryToken]�_registriesc�6�||vr2||}t|t�s"t|td|�g�x}||<n|||<	tt|d�}|j
j
d�}|rQ|jd�}|j|�}|D]}|j|�}�	|j||�|r�Pyy#t$rtdd�x|d<}Y��wxYw#t$r0}t|t�stjd|�d��|��d}~wwxYw)z^Add a class to the _decl_class_registry associated with the
    given declarative class.

    �	Type[Any]�_sa_module_registryN�.r�name "�-" matches both a class name and a module name)
�
isinstance�_MultipleClassMarkerr�
_ModuleMarker�KeyError�
__module__�split�pop�
get_module�	add_class�AttributeErrorr�InvalidRequestError)	�	classname�cls�decl_class_registry�existing�root_module�tokens�token�module�aes	         �K/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/clsregistry.pyr6r6@sQ���'�'�&�y�1���(�$8�9�8L��d�;��1�2�9�
�H�*�9�5�*-��I�&�
���.�/D�E�
���^�^�
!�
!�#�
&�F���
�
�1�
���'�'��.���E��&�&�u�-�F��		����Y��,����
��/��6�	
��1�2�[�
��.�	��f�m�4��-�-��Y�K�(3�3����
��	�s)�B?�(C�?C�C�	D�(+D�Dc���||vr*||}t|t�r|j|�n||=	tt|d�}|jjd�}|rQ|jd�}|j|�}|D]}|j|�}�	|j||�|r�Pyy#t
$rYywxYw#t$rt|t�sn�Y�1wxYw)Nr*r+r)r.r/�remove_itemrr0r1r2r3r4r5�remove_classr7)r9r:r;r<r=r>r?r@s        rBrErEvs����'�'�&�y�1���h� 4�5�� � ��%�#�I�.����.�/D�E�
���^�^�
!�
!�#�
&�F�
��
�
�1�
���'�'��.���E��&�&�u�-�F��	����	�3�/�
��������	��f�m�4����	�s#�B2�C�2	B>�=B>�C�Cc��||vry||}t|t�r&|jD]}||�s�ytd��||�S)a�test if a key is empty of a certain object.

    used for unit tests against the registry to see if garbage collection
    is working.

    "test" is a callable that will be passed an object should return True
    if the given object is the one we were looking for.

    We can't pass the actual object itself b.c. this is for testing garbage
    collection; the caller will have to have removed references to the
    object itself.

    TFzunknown codepath)r.r/�contents�NotImplementedError)�keyr;�test�thing�	sub_things     rB�
_key_is_emptyrM�sW��$�%�%����$�E��%�-�.����I��I���(�&�&8�9�9���;���c��eZdZdZdZy)r&zAan object that can be in the registry._class_registry as a value.�N)�__name__r2�__qualname__�__doc__�	__slots__rPrNrBr&r&�s
��K��IrNc�d�eZdZUdZdZded<ded<	d			dd�Zdd	�Zdd
�Zdd�Z	dd�Z
dd
�Zy)r/zRrefers to multiple classes of the same name
    within _decl_class_registry.

    )�	on_removerG�__weakref__zSet[weakref.ref[Type[Any]]]rGz/CallableReference[Optional[Callable[[], None]]]rVNc��||_|D�chc]"}tj||j���$c}|_t
j
|�ycc}w�N)rV�weakref�ref�_remove_itemrGr'�add)�self�classesrV�items    rB�__init__z_MultipleClassMarker.__init__�sJ��
#���=D�
�=D�T�G�K�K��d�/�/�0�W�
��
�	������
s�'Ac�L�|jtj|��yrY)r\rZr[�r^r:s  rBrDz _MultipleClassMarker.remove_item�s�����'�+�+�c�*�+rNc�(�d�|jD�S)Nc3�*K�|]}|����
y�wrYrP)�.0r[s  rB�	<genexpr>z0_MultipleClassMarker.__iter__.<locals>.<genexpr>�s����/��#����s��rG)r^s rB�__iter__z_MultipleClassMarker.__iter__�s��/����/�/rNc���t|j�dkDr+tjddj	||gz�z��t|j�d}|�}|�t
|��|S)NrzxMultiple classes found for path "%s" in the registry of this declarative base. Please use a fully module-qualified path.r+r)�lenrGrr8�join�list�	NameError)r^�pathrIr[r:s     rB�attempt_getz _MultipleClassMarker.attempt_get�su���t�}�}���!��)�)�B��8�8�D�C�5�L�)�+��
��t�}�}�%�a�(�C��%�C��{���n�$��JrNc��|jj|�|js3tj|�|jr|j�yyyrY)rG�discardr'rV)r^r[s  rBr\z!_MultipleClassMarker._remove_item�sD���
�
���c�"��}�}�����%��~�~���� ��rNc��t|j�D�cgc]	}|���c}D�chc]}|�|j��}}|j|vr0tjd|j�d|j
�d��|jj
tj||j��ycc}wcc}w)Nz[This declarative base already contains a class with the same class name and module name as r+z2, and will be replaced in the string-lookup table.)
rmrGr2r�warnrQr]rZr[r\)r^r`r[r:�moduless     rB�add_itemz_MultipleClassMarker.add_item�s���*.�d�m�m�)<�=�)<�#���)<�=�
�=����
�N�N�=�	�
�
�?�?�g�%��I�I��?�?�D�M�M�3�
�	
�
�
���'�+�+�d�D�,=�,=�>�?��>��
s
�B:�B?rY)r_zIterable[Type[Any]]rVzOptional[Callable[[], None]])r:r)�return�None)rwz*Generator[Optional[Type[Any]], None, None])ro�	List[str]rI�strrwr))r[zweakref.ref[Type[Any]]rwrx)r`r)rwrx)rQr2rRrSrT�__annotations__rarDrirpr\rvrPrNrBr/r/�sP���
7�I�)�)�>�>�
37�	�$�	�0�	�,�0�
�!�@rNr/c�~�eZdZUdZdZded<ded<ded<d	ed
<dd�Zdd�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
y)r0z>Refers to a module name within
    _decl_class_registry.

    )�parent�namerG�mod_nsrorW�Optional[_ModuleMarker]r}z5Dict[str, Union[_ModuleMarker, _MultipleClassMarker]]rG�_ModNSrryroc���||_||_i|_t|�|_|jr*|jj
|jgz|_ng|_tj|�yrY)r}r~rGr�rror'r])r^r~r}s   rBraz_ModuleMarker.__init__sX�������	���
��T�l����;�;����(�(�D�I�I�;�6�D�I��D�I�����rNc��||jvSrYrh�r^r~s  rB�__contains__z_ModuleMarker.__contains__s���t�}�}�$�$rNc� �|j|SrYrhr�s  rB�__getitem__z_ModuleMarker.__getitem__s���}�}�T�"�"rNc���|jj|d�|jsG|j�%|jj|j�t
j
|�yyrY)rGr4r}r\r~r'rrr�s  rBr\z_ModuleMarker._remove_item sP���
�
���$��%��}�}��{�{�&����(�(����3�����%�rNc�8�|jj|�SrY)r�__getattr__�r^rIs  rB�resolve_attrz_ModuleMarker.resolve_attr's���{�{�&�&�s�+�+rNc��||jvrt||�}||j|<|Stt|j|�}|SrY)rGr0r)r^r~�markers   rBr5z_ModuleMarker.get_module*sK���t�}�}�$�"�4��.�F�"(�D�M�M�$���
��-����t�)<�=�F��
rNc�>�����jvr0tt�j��}	|j|�yt|g��fd���x}�j�<y#t$r0}t|t�st
jd��d��|��d}~wwxYw)Nr,r-c�&���j��SrY)r\)r~r^s��rB�<lambda>z)_ModuleMarker.add_class.<locals>.<lambda>As����):�):�4�)@rN)rV)rGrr/rvr7r.rr8)r^r~r:r<rAs``   rBr6z_ModuleMarker.add_class2s�����4�=�=� ��0�$�-�-��2E�F�H�	
��!�!�#�&�.B���!@�.�
�H�t�}�}�T�*��"�
�!�(�,@�A��1�1� ���'7�7����
��
�s�A#�#	B�,+B�Bc�~�||jvr/tt|j|�}|j|�yyrY)rGrr/rD)r^r~r:r<s    rBrEz_ModuleMarker.remove_classDs7���4�=�=� ��0�$�-�-��2E�F�H�� � ��%�!rNN)r~rzr}r�)r~rzrw�bool)r~rzrwr&)r~rzrwrx�rIrzrwzUnion[_ModNS, Type[Any]])r~rzrwr0)r~rzr:r)rwrx)rQr2rRrSrTr{rar�r�r\r�r5r6rErPrNrBr0r0sM���
N�I�#�#�C�C��N�
�O�	�%�#�&�,���$&rNr0c�,�eZdZUdZded<dd�Zdd�Zy)	r�)�__parentr0�_ModNS__parentc��||_yrY)r�)r^r}s  rBraz_ModNS.__init__Os	����
rNc�J�	|jj|}|�Tt|t�r|jSt|t
�sJ�|j
|jj|�Std|jj�d|����#t$rY�0wxYw)NzModule z1 has no mapped classes registered under the name )r�rGr.r0rr/rpror1rnr~)r^rI�values   rBr�z_ModNS.__getattr__Rs���
	F��M�M�*�*�3�/�E�� ��e�]�3� �<�<�'�%�e�-A�B�B�B� �,�,�T�]�]�-?�-?��E�E��.2�m�m�.@�.@�#�
G�
�	
���	��	�s�B�	B"�!B"N)r}r0r��rQr2rRrTr{rar�rPrNrBr�r�Js���I����
rNr�c�,�eZdZUdZded<dd�Zdd�Zy)	�_GetColumns�r:r)r:c��||_yrYr�rcs  rBraz_GetColumns.__init__is	����rNc��t|jd��}|r�||jvrtd|j�d|����|j|}|jt
jjurmt|tj�sJ�|j}t|t�r
|j}n(t|t�stj d|z��t#|j|�S)NF)�	configurezClass z% does not have a mapped column named zaProperty %r is not an instance of ColumnProperty (i.e. does not correspond directly to a Column).)rr:�all_orm_descriptorsr7�extension_typer�NotExtension�
NOT_EXTENSIONr.r�QueryableAttribute�propertyrr~rrr8�getattr)r^rI�mp�desc�props     rBr�z_GetColumns.__getattr__ls���
�$�(�(�e�
4��
��"�0�0�0�$��x�x��&���
�)�)�#�.�D��"�"�j�&=�&=�&K�&K�K�!�$�
�(E�(E�F�F�F��}�}���d�O�4��)�)�C�#�D�.�9��1�1�2�47�8���
�t�x�x��%�%rNN)r:r)�rIrzrwrr�rPrNrBr�r�ds���I�	�N��&rNr�c�@�tj|j�SrY)r�inspectr:)�targets rBr�r��s��:�%�%�f�j�j�1rNc�6�eZdZUdZded<ded<d	d�Zd
d�Zy)�	_GetTable�rI�metadatarzrIr"r�c� �||_||_yrYr�)r^rIr�s   rBraz_GetTable.__init__�s����� ��
rNc�\�|jjt||j�SrY)r��tablesrrIr�s  rBr�z_GetTable.__getattr__�s"���}�}�#�#�N�3����$A�B�BrNN)rIrzr�r")rIrzrwr#r�rPrNrBr�r��s��!�I�	�H���!�CrNr�c�\�t|t�r|jg|�}t|�SrY)r.r/rpr�)rIr�s  rB�_determine_containerr��s*���%�-�.��!�!�"�c�*���u��rNc��eZdZUdZded<ded<ded<ded	<d
ed<ded
<	d									dd�Zdd�Zdd�Zdd�Zdd�Z	y)�_class_resolver)r:r��arg�fallback�_dict�
_resolvers�favor_tablesr)r:�RelationshipProperty[Any]r��Mapping[str, Any]r�rzr�r�r�z Tuple[Callable[[str], Any], ...]r�c��||_||_||_||_t	j
|j�|_d|_||_	y)NrP)
r:r�r�r�r�PopulateDict�_access_clsr�r�r�)r^r:r�r�r�r�s      rBraz_class_resolver.__init__�sG�������	���� ��
��&�&�t�'7�'7�8��
����(��rNc���|j}tj|�}|j}|�J�|j}|j
}|jrB||jvr|j|S||jvrt|t|d|��S||vrt|||�S|jsB||jvr|j|S||jvrt|t|d|��Sd|vr9|tt|d�vr$tt|d�}|j|�S|jr|jD]}||�}	|	��|	cS|j |S)Nr�r*)r:r�manager_of_class�registry�_class_registryr�r�r��_schemasr�r�r�rr0r�r�r�)
r^rIr:�manager�	decl_baser;r�r��resolvr�s
          rBr�z_class_resolver._access_cls�s~���h�h���-�-�c�2���$�$�	��$�$�$�'�7�7���%�%������h�o�o�%����s�+�+���)�)�)� ��g�c�:�x�&H�I�I��%�%�'��-@��-E�F�F�� � ��h�o�o�%����s�+�+���)�)�)� ��g�c�:�x�&H�I�I� �$7�7�C�4��.�/D�E�D
�=
���2�3H�I��H��(�(��-�-�
�_�_��/�/���s����$� �L�*�
�}�}�S�!�!rNc
���tjd|�}|r�|jd�jd�}t	j
d|jj�d|j�d|jj�d|jd��d	|�d
��|�t	j
d|jj�d|j�d|�d
|j�d�	�|�)Nz(.+)\[(.+)\]r�'zWhen initializing mapper z, expression "relationship(z�)" seems to be using a generic class as the argument to relationship(); please state the generic argument using an annotation, e.g. "z	: Mapped[rz['z']] = relationship()"z
, expression z failed to locate a name (zG). If this is a class name, consider adding this relationship() to the z6 class after both dependent classes have been defined.)�re�match�group�striprr8r�r}r�rIr:)r^r~�err�
generic_match�clsargs     rB�_raise_for_namez_class_resolver._raise_for_name�s�������$�7�
��"�(�(��+�1�1�#�6�F��)�)�+�D�I�I�,<�,<�+=�>,�,0�H�H�<�8��I�I�M�M�?�)�M�,?�,?��,B�+C��V�H�2�
4���
��)�)�
�9�9�#�#�T�X�X�t�T�X�X�	?���

rNc��|j}|j}d}	|jd�D]}|�||}�t||�}�	t	|t
�r|jStrt	|tttf�sJ�|S#t$r}|j||�Yd}~yd}~wt$r)}|j|jd|�Yd}~yd}~wwxYw)Nr+r)r�r�r3r�r.r�r:r�typer#r�r1r�rn�args)r^r~�d�rvalr?r��ns       rB�
_resolve_namez_class_resolver._resolve_name�s����x�x���J�J����	����C����<��U�8�D�"�4��/�D�	)��$��,��x�x�� �%�d�T�5�&�,A�B�B�B�����	,�� � ��s�+�+���	/�� � ������A�.�.��	/�s#�*B�	C�B(�(C�4C�Cc��	t|jt�|j�}t	|t
�r|jS|S#t$r)}|j|jd|�Yd}~yd}~wwxYw)Nr)
�evalr��globalsr�r.r�r:rnr�r�)r^�xr�s   rB�__call__z_class_resolver.__call__sb��	/��T�X�X�w�y�$�*�*�5�A��!�[�)��u�u������	/�� � ������A�.�.��	/�s�AA	�A	�		A;�A6�6A;N�F)
r:r)r�r�r�r�r�rzr�r�r�)r~rzr��	Exceptionrwr
)rwzUnion[Table, Type[Any], _ModNS])rwr)
rQr2rRrTr{rar�r�r�r�rPrNrBr�r��s|���I�
�N�
#�#���	�H���0�0�#�
)�
�)�(�)�$�	)�
�)��
)� %"�N�.�,	/rNr�r��_fallback_dictc�����t�Addl}ddlm}ddlm}tj|j�j||d��add	��fd�
}				d
��fd�}||fS)Nrr)�foreign)�remote)r�r�c�,��t��t||��S)N)r�)r�r�)r�r�r:r�s  ��rB�resolve_argz_resolver.<locals>.resolve_arg1s������~�s��
�	
rNc�<��t��t|�jSrY)r�r�r�)r�r:r�s ��rB�resolve_namez_resolver.<locals>.resolve_name6s����s�D�.�#�>�L�L�LrNr�)r�rzr�r�rwr�)r�rzrwz-Callable[[], Union[Type[Any], Table, _ModNS]])	r��
sqlalchemy�r�r�r�
immutabledict�__dict__�union)r:r�r�r�r�r�r�s``     rB�	_resolverr�"sg���������+�+�J�,?�,?�@�F�F��6�2�
��
�
M�
�M�	6�M�
��$�$rN)r9rzr:zType[_T]r;�_ClsRegistryTyperwrx)r9rzr:r)r;r�rwrx)rIrzr;r�rJzCallable[[Any], bool]rwr�)rIrzr�rrwr�)r:r)r�r�rwzmTuple[Callable[[str], Callable[[], Union[Type[Any], Table, _ModNS]]], Callable[[str, bool], _class_resolver]])?rS�
__future__rr��typingrrrrrr	r
rrr
rrrrrrrrZr�rr�descriptor_propsr�
propertiesrrrrr�
sql.schemar�util.typingr �
relationshipsr!r"r#r$rzr�r��setr'r{r6rErMr&r/r0r�r��	_inspectsr�r�r�r�r�rPrNrB�<module>r�s����#�	���������!������ ������-�&�����'�+��3�%�"��T����!�#�u�T�3E�-E�'F�"F�G��&)�U��
"�*�3��3�!�3�8H�3�	�3�l���"��9I��	��B�	��)�� ��
�	�@��B@�+�B@�JE&�$�E&�P
�
�4&�&�@"��
���[�!�1��
C�C��/�/�D%)��!�(�%rN

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic