Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
visitors.cpython-313.pyc417 linesDownload Raw Back to __pycache__
1�

2��ji���t�SrSSKJr SSKJr SSKJr SSKrSSKrSSK	r	SSK	J3r4 SSK	Jr SSK	Jr SS	K	J
r
 SS5K	Jr SSK	Jr SSK	Jr SS
K	Jr SSK	Jr SSK	Jr SSK	Jr SSK	Jr SSK	Jr SSK	Jr SSK	Jr SSK	Jr SSKJr SSKJr SSKJr SSKJr SSK J!r! SSK J"r" SSK J#r# \(aSSK$J%r% SS K&J'r' \	R.(d\(d
SS!K(J)r) SS"K(J*r+ OSS!K,J)r) SS"K,J*r+ /S#Qr-"S$S%\"5r."S&S'5r/"S(S)\5r0\\\1\04r2"S*S+5r3"S,S-\"5r4"S.S/5r5\0r6SPS0jr7\5Rpr8\7"5 "S1S2\3\/5r9\"S3\9S49r:\"S5S6S49r;\\:/S4r<"S7S8\"5r="S9S:\"\:5r>\"S;S<S49r?"S=S<\R�5rA"S>S?\A5rB"S@SA\B5rC\/rD\ArE\BrF\CrG\R�4SQSBjjrI\SRSCj5rJ\SSSDj5rJSTSEjrJ\SUSFj5rK\SVSGj5rKSWSHjrK\SUSIj5rL\SXSJj5rLSWSKjrL\SYSLj5rM\SZSMj5rM\S[SNj5rMS\SOjrMg)]z2Visitor/traversal interface and library functions.�)�annotations)�deque)�EnumN)�Any)�Callable)�cast)�ClassVar)�Dict)�Iterable)�Iterator)�List)�Mapping)�Optional)�overload)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�exc)�util)�langhelpers)�HAS_CYEXTENSION)�Literal)�Protocol)�Self�)�_AnnotationDict)�
ColumnElement)�prefix_anon_map)�cache_anon_map)	�iterate�traverse_using�traverse�cloned_traverse�replacement_traverse�	Visitable�ExternalTraversal�InternalTraversal�anon_mapc��\rSrSrSSjrSrg)�_CompilerDispatchType�Gc��g�N�)�_self�self�visitor�kws    �]D:\code\apps\devtools\python\user_packages\Python313\site-packages\sqlalchemy/sql/visitors.py�__call__�_CompilerDispatchType.__call__Hs��#�r1N)r3r(r4rr5r�returnr��__name__�6__module__�__qualname__�__firstlineno__r7�__static_attributes__r1r9r6r-r-Gs��Mr9r-c�^�\rSrSr%SrSrS\S'S\S'\R(aSSjr	S
U4S	jjr7\S
S8j5rSSjr
SrU=r$)r(�KaBase class for visitable objects.9 10:class:`.Visitable` is used to implement the SQL compiler dispatch11functions.    Other forms of traversal such as for cache key generation12are implemented separately using the :class:`.HasTraverseInternals`13interface.14 15.. versionchanged:: 2.0  The :class:`.Visitable` class was named16   :class:`.Traversible` in the 1.4 series; the name is changed back17   to :class:`.Visitable` in 2.0 which is what it was prior to 1.4.18 19   Both names remain importable in both 1.4 and 2.0 versions.20 21r1�str�__visit_name__r-�_original_compiler_dispatchc��gr0r1)r3r4r5s   r6�_compiler_dispatch�Visitable._compiler_dispatchcs��cr9c�b>�SUR;aUR5 [TU]
5 g)NrD)�__dict__�_generate_compiler_dispatch�super�__init_subclass__)�cls�	__class__s �r6rM�Visitable.__init_subclass__es&����s�|�|�+��+�+�-�
��!�#r9c�F^�URnSUR;aURUlg[	U[225(d$[R"SURS35eSU-n[R"U5mSU4SjjnU=UlUlg)NrGz__visit_name__ on class z$ must be a string at the class level�visit_%sc�|>�T"U5nU"U40UD6$![anUR"X40UD6sSnA$SnAff=f)zgLook for an attribute named "visit_<visit_name>" on the23visitor, and call it with the same kw params.24 25N)�AttributeError�visit_unsupported_compilation)r3r4r5�meth�err�getters     �r6rG�AVisitable._generate_compiler_dispatch.<locals>._compiler_dispatch~sM���
(��g����D�'�B�'�'��"�
N��<�<�T�M�"�M�M��
N�s��26;�6�;�;)r3r(r4rr5rr:rC)rDrJrGrE�27isinstancerCr�InvalidRequestErrorr<�operator�28attrgetter)rN�29visit_name�namerGrXs    @r6rK�%Visitable._generate_compiler_dispatchjs�����'�'�30��3�<�<�/�/2�.D�.D�C�+���*�c�*�*��)�)�*�3�<�<�.�9%�%��
�31�J�&���$�$�T�*��	(��	(�&)�	(�14�	(�
�	(� 
�	����+r9c��U$r0r1)rN�keys  r6�__class_getitem__�Visitable.__class_getitem__�s���32r9)r4rr5rr:rC�r:�None)rbrr:r)r<r=r>r?�__doc__�	__slots__�__annotations__�typingrrGrM�classmethodrKrcr@�
__classcell__)rOs@r6r(r(KsK���
��I���!6�6�
���I�$�33�#��#�J�r9r(c���\rSrSrSrSrSrSrSrSr	Sr34S	rS35rSr
SrS
rSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSr Sr!S r"S!r#S"r$S#r%S$r&S%r'S&r(S'r)S(r*S)r+S*r,g+),r*�a�Defines visitor symbols used for internal traversal.36 37The :class:`.InternalTraversal` class is used in two ways.  One is that38it can serve as the superclass for an object that implements the39various visit methods of the class.   The other is that the symbols40themselves of :class:`.InternalTraversal` are used within41the ``_traverse_internals`` collection.   Such as, the :class:`.Case`42object defines ``_traverse_internals`` as ::43 44    class Case(ColumnElement[_T]):45        _traverse_internals = [46            ("value", InternalTraversal.dp_clauseelement),47            ("whens", InternalTraversal.dp_clauseelement_tuples),48            ("else_", InternalTraversal.dp_clauseelement),49        ]50 51Above, the :class:`.Case` class indicates its internal state as the52attributes named ``value``, ``whens``, and ``else_``.    They each53link to an :class:`.InternalTraversal` method which indicates the type54of datastructure to which each attribute refers.55 56Using the ``_traverse_internals`` structure, objects of type57:class:`.InternalTraversible` will have the following methods automatically58implemented:59 60* :meth:`.HasTraverseInternals.get_children`61 62* :meth:`.HasTraverseInternals._copy_internals`63 64* :meth:`.HasCacheKey._gen_cache_key`65 66Subclasses can also implement these methods directly, particularly for the67:meth:`.HasTraverseInternals._copy_internals` method, when special steps68are needed.69 70.. versionadded:: 1.471 72�HC�HL�CE�FC�CTS�CL�CT�EO�WC�CO�S�SL�AN�B�O�T�PD�DO�CD�MD�AK�PO�DD�PS�TH�SJ�ME�SH�UK�DML_OV�DML_V�DML_MV�PA�IG�IS�M�MT�HT�ILr1N)-r<r=r>r?rg�dp_has_cache_key�dp_has_cache_key_list�dp_clauseelement�)dp_fromclause_canonical_column_collection�dp_clauseelement_tuples�dp_clauseelement_list�dp_clauseelement_tuple�dp_executable_options�dp_with_context_options�dp_fromclause_ordered_set�	dp_string�dp_string_list�dp_anon_name�73dp_boolean�dp_operator�dp_type�
dp_plain_dict�dp_dialect_options�dp_string_clauseelement_dict�dp_string_multi_dict�dp_annotations_key�dp_plain_obj�dp_named_ddl_element�dp_prefix_sequence�dp_table_hint_list�dp_setup_join_tuple�dp_memoized_select_entities�dp_statement_hint_list�dp_unknown_structure�dp_dml_ordered_values�
dp_dml_values�dp_dml_multi_values�dp_propagate_attrs�	dp_ignore�dp_inspectable�dp_multi�
dp_multi_list�dp_has_cache_key_tuples�dp_inspectable_listr@r1r9r6r*r*�s���%�N��/� ��8���<�04�-�	�$���74!���"���!��"�� $��K��I���N�"��L���J���K���G���M����,�#'� ��75 ���76����L�� ������77���78��"&��!��� ���%��+��M��79#���80��)���I���N�%��H���M�'�#���81��r9r*c�|�\rSrSr%SrSrS\S'SrS\S'\R"S	5SS82.S
Sjj5r83Srg)�HasTraverseInternalsi�a�base for classes that have a "traverse internals" element,84which defines all kinds of ways of traversing the elements of an object.85 86Compared to :class:`.Visitable`, which relies upon an external visitor to87define how the object is traversed (i.e. the :class:`.SQLCompiler`), the88:class:`.HasTraverseInternals` interface allows classes to define their own89traversal, that is, what attributes are accessed and in what order.90 91r1�_TraverseInternalsType�_traverse_internalsF�bool�
_is_immutablezsqlalchemy.sql.traversals��92omit_attrsc�^^�[RRnURnUR93Rn[RRUU4SjU"XS555$![a /s$f=f)a�Return immediate child :class:`.visitors.HasTraverseInternals`94elements of this :class:`.visitors.HasTraverseInternals`.95 96This is used for visit traversal.97 98\**kw may contain flags that change the collection that is99returned, for example to return a subset of items in order to100cut down on larger traversals, or to return child items from a101different context (such as schema-level collections instead of102clause-level).103 104c3�V># �UHupnUT;dMUcMU"U40TD6v� M  g7fr0r1)�.0�attrname�objrVr5r�s    ��r6�	<genexpr>�4HasTraverseInternals.get_children.<locals>.<genexpr>�s?����-105�(�#��t��z�)�	
�/2�	
�D��O��O�(�s�
)�)�)�!_generated_get_children_traversal)106r�	preloaded�sql_traversalsr�rT�
_get_children�run_generated_dispatch�	itertools�chain�
from_iterable)r3r�r5�107traversals�traverse_internals�dispatchs ``   r6�get_children�!HasTraverseInternals.get_children�s}���"�^�^�2�2�108�	�!%�!9�!9��109�+�+�B�B�����,�,�-110�'/��*M�(�-111�112�	113���	��I�	�s�A1�1B�?BN)r��Tuple[str, ...]r5rr:zIterable[HasTraverseInternals])r<r=r>r?rgrhrir�r�preload_moduler�r@r1r9r6r�r��sW����I�/�/��M�4��	���4�5�/1�114�,�115�9<�116�	'�117�6�118r9r�c��\rSrSrSSjrSrg)�_InternalTraversalDispatchTypei�c��gr0r1)�sr3r4s   r6r7�'_InternalTraversalDispatchType.__call__�s��r9r1N)r3�objectr4�HasTraversalDispatchr:rr;r1r9r6r�r��s��Lr9r�c��\rSrSr%SrSr0rS\S'SSjrSSjr	S
Sjr119SS	jrSrg120)r�i�z[Define infrastructure for classes that perform internal traversals121 122.. versionadded:: 2.0123 124r1z2ClassVar[Dict[Union[InternalTraversal, str], str]]�_dispatch_lookupc�,�[Un[XS5$)zdGiven a method from :class:`.HasTraversalDispatch`, return the125corresponding method on a subclass.126 127N)r��getattr)r3�visit_symbolr_s   r6r��HasTraversalDispatch.dispatch�s��128 ��-���t�4�(�(r9c��URRUnU"X5$![a URURX#5nN0f=fr0)rOrJ�KeyError�generate_dispatch)r3�target�internal_dispatch�generate_dispatcher_name�129dispatchers     r6r��+HasTraversalDispatch.run_generated_dispatchsZ��		��)�)�2�2�3K�L�J��&�'�'���	�130�/�/�� � �"3��J�	�s�#�&A�Ac�@�URX#5n[XU5 U$r0)�_generate_dispatcher�setattr)r3�131target_clsr�r�r�s     r6r��&HasTraversalDispatch.generate_dispatchs)���.�.��132�133�	�134�j�A��r9c��/nUH6upEURU5nUcM[UnURXG45 M8 SSRSU55-S-nSU-U-S-n	[	[135[R"U	0U55$)Nz
    return [136z, 137c3�D# �UHupSU<SU<SU<S3v� M g7f)z	        (z, self.z138, visitor.�)Nr1)r�r�r^s   r6r��<HasTraversalDispatch._generate_dispatcher.<locals>.<genexpr>.s'����16�,��*� ��:�7�05�s� z139    ]140zdef %s(self, visitor):141�142)r�r��append�joinrr�r�_exec_code_in_env)143r3r��method_name�namesr��	visit_symrVr^�code�	meth_texts144          r6r��)HasTraversalDispatch._generate_dispatcher!s�����#4��H��=�=��+�D���-�i�8�145����h�3�4�	$5������16���
��
�	
�0�+�=��E��L�	��*��)�)�)�R��E�146�	147r9N)r�r*r:zCallable[..., Any])r�r�r�r�r�rCr:r)r�zType[object]r�r�r�rCr:r�)r�r�r�rCr:r�)
r<r=r>r?rgrhr�rir�r�r�r�r@r1r9r6r�r��s�����I�KM��H�M�)�(��(�2�(�#&�	(�148149
�(�&� ��2��#&�	�150151(��152�!7�153�FI�154�	'�155r9r�c���[n[HYnURnURS5(dM'UR	SS5nUR156nX@;dU5eU=X'X'M[ g)N�dp_�visit_)r�r*r_�157startswith�replace�value)�lookup�symrb�	visit_key�sym_names     r6�_generate_traversal_dispatchr
@sb��
�F� ���h�h���>�>�%� � ����E�8�4�I��y�y�H��)�3�8�3�)�-6�6�F�K�&�*�
!r9c��\rSrSr%Sr\RrS\S'\	R(aSSjrSS.SSjjrS
Sjr
SS.SS	jjrSrg158)�ExternallyTraversibleiPr1zMapping[Any, Any]�_annotationsc��gr0r1)r3�valuess  r6�	_annotate�ExternallyTraversible._annotateWs��cr9r�c��gr0r1�r3r�r5s   r6r��"ExternallyTraversible.get_childrenYs��.1r9c��[5e)zclone this element��NotImplementedError)r3r5s  r6�_clone�ExternallyTraversible._clone]s��!�#�#r9c��[5e)aDReassign internal elements to be clones of themselves.159 160Called during a copy-and-traverse operation on newly161shallow-copied elements to create a deep copy.162 163The given clone function should be used, which may be applying164additional transformations to the element (i.e. replacement165traversal, cloned traversal, annotations).166 167rrs   r6�_copy_internals�%ExternallyTraversible._copy_internalsas
��"�#�#r9N)rrr:r)r�r�r5rr:�Iterable[ExternallyTraversible])r5rr:r)r�r�r5rr:rf)r<r=r>r?rhr�168EMPTY_DICTrrirjrrr�rrr@r1r9r6rrPsp���I�&*�o�o�L�#�5�
���A�46�	2�!0�	2�=@�	2�
,�	2�$�16902�
$�,�
$�9<�
$�	
�
$�
$r9r�_ET)�bound�_CEzColumnElement[Any]c��\rSrSrSSjrSrg)�_CloneCallableTypeixc��gr0r1�r3�elementr5s   r6r7�_CloneCallableType.__call__ys��r9r1N)r)r"r5rr:r"r;r1r9r6r&r&xs��;r9r&c��\rSrSrSSjrSrg)�_TraverseTransformCallableTypei|c��gr0r1r(s   r6r7�'_TraverseTransformCallableType.__call__}s��#r9r1N)r)r"r5rr:z
Optional[_ET]r;r1r9r6r,r,|s��Er9r,�_ExtTr)c���\rSrSr%SrSr0rS\S'S\S'SSjrSS	jr	\170SS171j5r\172SSj5rSSjrSS
jr\
SSj5rSSjrSrg)r)i�z�Base class for visitor objects which can traverse externally using173the :func:`.visitors.traverse` function.174 175Direct usage of the :func:`.visitors.traverse` function is usually176preferred.177 178)�
_visitor_dict�_nextzDict[str, Any]�__traverse_options__zOptional[ExternalTraversal]r2c��URH/n[USUR-S5nU(dM&U"U40UD6s $ g)NrR)�visitor_iteratorr�rD)r3r�r5�vrVs     r6�traverse_single�!ExternalTraversal.traverse_single�s>���&�&�A��1�j�3�+=�+=�=�t�D�D��t��C��2��&�'r9c�,�[XR5$)zQTraverse the given expression structure, returning an iterator179of all elements.180 181)r#r3�r3r�s  r6r#�ExternalTraversal.iterate�s���s�5�5�6�6r9c��gr0r1r:s  r6r%�ExternalTraversal.traverse����47r9c��gr0r1r:s  r6r%r=����!$r9c�B�[XRUR5$��2Traverse and visit the given expression structure.)r%r3r1r:s  r6r%r=�s��182��6�6��8J�8J�K�Kr9c�~�0n[U5H+nURS5(dM[X5XSS'M- U$)Nr�)�dirrr�)r3�visitorsr_s   r6�_memoized_attr__visitor_dict�.ExternalTraversal._memoized_attr__visitor_dict�s@������I�D����x�(�(�%,�T�%8��a�b��"���r9c#�T# �UnU(aUv� [USS5nU(aMgg7f)z8Iterate through this visitor and each 'chained' visitor.r2N)r�)r3r6s  r6r5�"ExternalTraversal.visitor_iterator�s)���*.����G���7�D�)�A��a�s�"(�(c�B�[UR5SnXlU$)z�'Chain' an additional ExternalTraversal onto this ExternalTraversal183 184The chained visitor will receive all visit events after this one.185 186�����)�listr5r2)r3r4�tails   r6r��ExternalTraversal.chain�s#���D�)�)�*�2�.���187��r9r1N)r�r(r5rr:r)r��Optional[ExternallyTraversible]r:�Iterator[ExternallyTraversible]�r��
Literal[None]r:rf�r�rr:r�r�rQr:rQ)r:z%Dict[str, _TraverseCallableType[Any]])r:zIterator[ExternalTraversal])r3r/r4r)r:r/)r<r=r>r?rgrhr3rir7r#rr%rH�propertyr5r�r@r1r9r6r)r)�s����+�I�+-��.�-�&�&�'�7�2�7�	(�7��7��7�
�$�(�$�	�$��$�L�2�L�	(�L��	.���*��*�r9c�p�\rSrSrSrSrS	Sjr\S188Sj5r\SSj5rSSjrSr	g)
�CloningExternalTraversali�z�Base class for visitor objects which can traverse using189the :func:`.visitors.cloned_traverse` function.190 191Direct usage of the :func:`.visitors.cloned_traverse` function is usually192preferred.193 194 195r1c�N�UVs/sHo RU5PM sn$s snf)zPApply cloned traversal to the given list of elements, and return196the new list.197 198)r%)r3�list_�xs   r6�copy_and_process�)CloningExternalTraversal.copy_and_process�s#��+0�0�%�Q�
�
�a� �%�0�0��0s�"c��gr0r1r:s  r6r%�!CloningExternalTraversal.traverse�r>r9c��gr0r1r:s  r6r%r`�r@r9c�B�[XRUR5$rB)r&r3r1r:s  r6r%r`�s"��199��*�*�D�,>�,>�200�	201r9N)r[�List[ExternallyTraversible]r:rcrSrUrV)202r<r=r>r?rgrhr]rr%r@r1r9r6rYrY�sj����I�1�0�1�	$�1��7��7�
�$�(�$�	�$��$�203�2�204�	(�205r9rYc�p�\rSrSrSrSrS	Sjr\S206Sj5r\SSj5rSSjrSr	g)
�ReplacingExternalTraversali�z�Base class for visitor objects which can traverse using207the :func:`.visitors.replacement_traverse` function.208 209Direct usage of the :func:`.visitors.replacement_traverse` function is210usually preferred.211 212r1c��g)z�Receive pre-copied elements during a cloning traversal.213 214If the method returns a new element, the element is used215instead of creating a simple copy of the element.  Traversal216will halt on the newly returned element if it is re-encountered.217Nr1)r3�elems  r6r�"ReplacingExternalTraversal.replace�s��r9c��gr0r1r:s  r6r%�#ReplacingExternalTraversal.traverse218r>r9c��gr0r1r:s  r6r%rj
r@r9c�N^�SU4Sjjn[UTRU5$)rCc�x>�TRH)n[[U5RU5nUcM'Us $ gr0)r5rrer)r)r5r6�er3s    �r6r�4ReplacingExternalTraversal.traverse.<locals>.replaces<����*�*���3�Q�7�?�?��H���=��H�+�219r9)r)rr5rr:rQ)r'r3)r3r�rs`  r6r%rjs9���220		�*�		��		�-�		�$�C��)B�)B�G�L�Lr9N)rgrr:rQrSrUrV)221r<r=r>r?rgrhrrr%r@r1r9r6rere�sm����I�	�)�	�	(�	��7��7�
�$�(�$�	�$��$�M�2�M�	(�Mr9rec#�# �UcgUv� UR"S0UD6nU(dg[U/5nU(aHUR5nUH(nUv� URUR"S0UD65 M* U(aMGgg7f)aTraverse the given expression structure, returning an iterator.222 223Traversal is configured to be breadth-first.224 225The central API feature used by the :func:`.visitors.iterate`226function is the227:meth:`_expression.ClauseElement.get_children` method of228:class:`_expression.ClauseElement` objects.  This method should return all229the :class:`_expression.ClauseElement` objects which are associated with a230particular :class:`_expression.ClauseElement` object. For example, a231:class:`.Case` structure will refer to a series of232:class:`_expression.ColumnElement` objects within its "whens" and "else\_"233member variables.234 235:param obj: :class:`_expression.ClauseElement` structure to be traversed236 237:param opts: dictionary of iteration options.   This dictionary is usually238 empty in modern usage.239 240Nr1)r�r�popleftr�)r��opts�children�stack�241t_iterator�ts      r6r#r#-su���0�{��242
�I����'�$�'�H����8�*��E�243��]�]�_�244��A��G��L�L����/�$�/�0���%�s�A;B�?Bc��gr0r1��iteratorr�rGs   r6r$r$V���245r9c��gr0r1rxs   r6r$r$^���246 r9c�r�UH0nURURS5nU(dM(U"U5 M2 U$)a�Visit the given expression structure using the given iterator of247objects.248 249:func:`.visitors.traverse_using` is usually called internally as the result250of the :func:`.visitors.traverse` function.251 252:param iterator: an iterable or sequence which will yield253 :class:`_expression.ClauseElement`254 structures; the iterator is assumed to be the255 product of the :func:`.visitors.iterate` function.256 257:param obj: the :class:`_expression.ClauseElement`258 that was used as the target of the259 :func:`.iterate` function.260 261:param visitors: dictionary of visit functions.  See :func:`.traverse`262 for details on this dictionary.263 264.. seealso::265 266    :func:`.traverse`267 268 269N)�getrD)ryr�rGr�rVs     r6r$r$fs7��:���|�|�F�1�1�4�8���4���L���Jr9c��gr0r1�r�rrrGs   r6r%r%�rzr9c��gr0r1r�s   r6r%r%�r|r9c�,�[[X5X5$)a�Traverse and visit the given expression structure using the default270iterator.271 272 e.g.::273 274    from sqlalchemy.sql import visitors275 276    stmt = select(some_table).where(some_table.c.foo == "bar")277 278 279    def visit_bindparam(bind_param):280        print("found bound value: %s" % bind_param.value)281 282 283    visitors.traverse(stmt, {}, {"bindparam": visit_bindparam})284 285The iteration of objects uses the :func:`.visitors.iterate` function,286which does a breadth-first traversal using a stack.287 288:param obj: :class:`_expression.ClauseElement` structure to be traversed289 290:param opts: dictionary of iteration options.   This dictionary is usually291 empty in modern usage.292 293:param visitors: dictionary of visit functions.   The dictionary should294 have strings as keys, each of which would correspond to the295 ``__visit_name__`` of a particular kind of SQL expression object, and296 callable functions  as values, each of which represents a visitor function297 for that kind of object.298 299)r$r#r�s   r6r%r%�s��H�'�#�,�c�<�<r9c��gr0r1r�s   r6r&r&�rzr9c��gr0r1r�s   r6r&r&����300r9c�^^^^^�0m[TRS/55mSUU4SjjnSUUUU4SjjmUbT"U4SU0TD6nSmU$)a�Clone the given expression structure, allowing modifications by301visitors for mutable objects.302 303Traversal usage is the same as that of :func:`.visitors.traverse`.304The visitor functions present in the ``visitors`` dictionary may also305modify the internals of the given structure as the traversal proceeds.306 307The :func:`.cloned_traverse` function does **not** provide objects that are308part of the :class:`.Immutable` interface to the visit methods (this309primarily includes :class:`.ColumnClause`, :class:`.Column`,310:class:`.TableClause` and :class:`.Table` objects). As this traversal is311only intended to allow in-place mutation of objects, :class:`.Immutable`312objects are skipped. The :meth:`.Immutable._clone` method is still called313on each object to allow for objects to replace themselves with a different314object based on a clone of their sub-internals (e.g. a315:class:`.ColumnClause` that clones its subquery to return a new316:class:`.ColumnClause`).317 318.. versionchanged:: 2.0  The :func:`.cloned_traverse` function omits319   objects that are part of the :class:`.Immutable` interface.320 321The central API feature used by the :func:`.visitors.cloned_traverse`322and :func:`.visitors.replacement_traverse` functions, in addition to the323:meth:`_expression.ClauseElement.get_children`324function that is used to achieve325the iteration, is the :meth:`_expression.ClauseElement._copy_internals`326method.327For a :class:`_expression.ClauseElement`328structure to support cloning and replacement329traversals correctly, it needs to be able to pass a cloning function into330its internal members in order to make copies of them.331 332.. seealso::333 334    :func:`.visitors.traverse`335 336    :func:`.visitors.replacement_traverse`337 338�stop_onc�>�[UTT5$r0)r&r�s ��r6�deferred_copy_internals�0cloned_traverse.<locals>.deferred_copy_internalss����s�D�(�3�3r9c�>�UT;aU$[U5T;a�SU;a3[[[US"U55nUbUT[U5'U$UR"SST0UD6=T[U5'nUR339"SST0UD6 UR(d+TRURS5nU(aU"U5 T[U5$)Nr�cloner1)	�idrrrrrr�r~rD)rgr5�newelemrVr��clonedr�rGs    ����r6r��cloned_traverse.<locals>.clone340s�����7�?��K��$�x�v�%���?�"� �!6�7��I��t�9L��G��*�+2��r�$�x�(�&��.2�[�[�-K�u�-K��-K�K��r�$�x� �7��'�'�:�e�:�r�:�341�)�)�#�<�<��(>�(>��E�D���W�
��"�T�(�#�#r9Nr�rU�rgrr5rr:r)�setr~)r�rrrGr�r�r�r�s `` @@@r6r&r&�st���Z02�F��$�(�(�9�b�)�*�G�4�
"�4�	�4�4�342$�$�<����343�)@�344�DH�345��
�E��Jr9c��gr0r1�r�rrrs   r6r'r'0rzr9c��gr0r1r�s   r6r'r'8r�r9c��gr0r1r�s   r6r'r'@r|r9c��^^^^^�0mTRS/5Vs1sHn[U5iM snmSUU4SjjnSUUUU4SjjmUbT"U4SU0TD6nSmU$s snf)aClone the given expression structure, allowing element346replacement by a given replacement function.347 348This function is very similar to the :func:`.visitors.cloned_traverse`349function, except instead of being passed a dictionary of visitors, all350elements are unconditionally passed into the given replace function.351The replace function then has the option to return an entirely new object352which will replace the one given.  If it returns ``None``, then the object353is kept in place.354 355The difference in usage between :func:`.visitors.cloned_traverse` and356:func:`.visitors.replacement_traverse` is that in the former case, an357already-cloned object is passed to the visitor function, and the visitor358function can then manipulate the internal state of the object.359In the case of the latter, the visitor function should only return an360entirely different object, or do nothing.361 362The use case for :func:`.visitors.replacement_traverse` is that of363replacing a FROM clause inside of a SQL structure with a different one,364as is a common use case within the ORM.365 366r�c�>�[UTT5$r0)r'r�s ��r6r��5replacement_traverse.<locals>.deferred_copy_internalsgs���$�C��w�7�7r9c�L>�[U5T;dSUR;aU$T"U5nUbTR[U55 U$[U5nUT;aFSU;aUS"U5nUbUTU'U$UR"S0UD6=TU'nUR"SST0UD6 TU$)N�no_replacement_traverserr�r1)r�r�addrr)rgr5r��id_elemr�r�rr�s    ����r6r��#replacement_traverse.<locals>.clonels�����t�H���(�D�,=�,=�=��K��d�m�G��"����B�w�K�(���367�T�(���&�(� �B��"$�Y�-��"5��"�.�.5�F�7�O�#*�N�04���0A�b�0A�A�F�7�O�g��+�+�>�%�>�2�>��g��&r9Nr�rUr�)r~r�)r�rrrr\r�r�r�r�s ``  @@@r6r'r'Hs����8�F�"�h�h�y�"�5�6�5��r�!�u�5�6�G�8�
"�8�	�8�8�368'�'�6����369�)@�370�DH�371��
�E��J��O7s�Are)r�rQrr�Mapping[str, Any]r:rR)ryr r�rTrG�(Mapping[str, _TraverseCallableType[Any]]r:rf)ryr r�rrGr�r:r)ryr r�rQrGr�r:rQ)r�rTrrr�rGr�r:rf)r�rrrr�rGr�r:r)r�rQrrr�rGr�r:rQ)r�r"rrr�rGr�r:r")r�rTrrr�r�#_TraverseTransformCallableType[Any]r:rf)r�r$rrr�rr�r:r$)r�rrrr�rr�r:r)r�rQrrr�rr�r:rQ)Nrg�372__future__r�collectionsr�enumrr�r\rjrrrr	r373rrr
rrrrrrrr�rrr�util._has_cyr�util.typingrrr�374annotationr�elementsr �_py_utilr!r"r+�sqlalchemy.cyextension.util�__all__r-r(r*rCr�r�r�r��ExtendedInternalTraversalr
r�rr"r$�_TraverseCallableTyper&r,r/�
MemoizedSlotsr)rYre�Traversible�
ClauseVisitor�CloningVisitor�ReplacingCloningVisitorr!r#r$r%r&r'r1r9r6�<module>r�s���9�"�����
�������������� ������*�!�"���+�'�	����<�4���375 376��N�H�N�G�G�TP��P�f�e�C�):�$:�;�<��377�1378�1379�hM�X�M�L380�L381�^.��	7�(�8�8����$�0�)�$�B�e�0�1��
�e�/�0�� �#����-��<��<�F�X�c�]�F�	��2�3��G��*�*�G�T$382�0�$383�N.M�!9�.M�d��!�
�)��4��384#�o�o�&1�	(�&1�385�&1�%�&1�R386��-��	��7��387�	�388��389� �-� �	� �7� ��	 �390� �!�-�!�	(�!�7�!�%�	!�H391��	��392��7��393�	�394��395� �	� �396� �7� ��	 �397� �$=�	(�$=�398�$=�7�$=�%�	$=�N399��	��400��7��401�	�402��403��	��404��7��	�	�405��X�	(�X�406�X�7�X�%�	X�v407��	��408��1��409�	�410��411��	��412��1��	�	�413��414� �	� �415� �1� ��	 �416� �D�	(�D�417�D�1�D�%�	Dr9
codekingpro/portable-devtools · Team Ai