zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
U
¸ý°d ’ã    @s>dZddlmZddlmZddlmZddlZddlZddl    Z    ddl    m
Z
ddl    m Z ddl    m Z dd    l    m Z dd
l    mZdd l    mZdd l    mZdd l    mZddl    mZddl    mZddl    mZddl    mZddl    mZddl    mZddl    mZddl    mZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl m#Z#errddl$m%Z%dd l&m'Z'e    js€esšdd!l(m)Z)dd"l(m*Z+ndd!l,m)Z)dd"l,m*Z+d#d$d%d&d'd(d)d*d+g    Z-Gd,d-„d-e"ƒZ.Gd.d(„d(ƒZ/Gd/d*„d*eƒZ0eee1e0fZ2Gd0d1„d1ƒZ3Gd2d3„d3e"ƒZ4Gd4d5„d5ƒZ5e0Z6d6d7œd8d9„Z7e5j8Z8e7ƒGd:d;„d;e3e/ƒZ9ed<e9d=Z:ed>d?d=Z;e e:gdfZ<Gd@dA„dAe"ƒZ=GdBdC„dCe"e:ƒZ>edDd)d=Z?GdEd)„d)ej@ƒZAGdFdG„dGeAƒZBGdHdI„dIeBƒZCe/ZDeAZEeBZFeCZGejHfdJdKdLdMœdNd#„ZIedOdPdQd6dRœdSd$„ƒZJedOd;dQd;dRœdTd$„ƒZJdOdJdQdJdRœdUd$„ZJedPdKdQd6dVœdWd%„ƒZKed;dKdQd;dVœdXd%„ƒZKdJdKdQdJdVœdYd%„ZKedPdKdQd6dVœdZd&„ƒZLed<dKdQd<dVœd[d&„ƒZLdJdKdQdJdVœd\d&„ZLedPdKd]d6d^œd_d'„ƒZMed>dKd]d>d^œd`d'„ƒZMed;dKd]d;d^œdad'„ƒZMdJdKd]dJd^œdbd'„ZMdS)cz5Visitor/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@s eZdZdddddœdd„ZdS)Ú_CompilerDispatchTyper'r©ÚselfÚvisitorÚkwÚreturncKsdS©N©)Ú_selfr-r.r/r2r2úNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/sql/visitors.pyÚ__call__Ksz_CompilerDispatchType.__call__N©Ú__name__Ú
__module__Ú __qualname__r5r2r2r2r4r+Jsr+csveZdZUdZdZded<ded<ejr:ddddœd    d
„Zd d œ‡fd d„ Z    e
d d œdd„ƒZ dddœdd„Z ‡Z S)r'a,Base class for visitable objects.
 
    :class:`.Visitable` is used to implement the SQL compiler dispatch
    functions.    Other forms of traversal such as for cache key generation
    are implemented separately using the :class:`.HasTraverseInternals`
    interface.
 
    .. versionchanged:: 2.0  The :class:`.Visitable` class was named
       :class:`.Traversible` in the 1.4 series; the name is changed back
       to :class:`.Visitable` in 2.0 which is what it was prior to 1.4.
 
       Both names remain importable in both 1.4 and 2.0 versions.
 
    r2ÚstrÚ__visit_name__r+Ú_original_compiler_dispatchr)r.r/r0cKsdSr1r2)r-r.r/r2r2r4Ú_compiler_dispatchgszVisitable._compiler_dispatchÚNone©r0cs d|jkr| ¡tƒ ¡dS)Nr;)Ú__dict__Ú_generate_compiler_dispatchÚsuperÚ__init_subclass__)Úcls©Ú    __class__r2r4rCjs
zVisitable.__init_subclass__cst|j}d|jkr|j|_dSt|tƒs:t d|j›d¡‚d|}t     
|¡‰dddddœ‡fd    d
„ }||_|_dS) Nr=z__visit_name__ on class z$ must be a string at the class levelúvisit_%sr'rr:r,c
sTz ˆ|ƒ}Wn6tk
rB}z|j||f|ŽWY¢Sd}~XYnX||f|ŽSdS)zLook for an attribute named "visit_<visit_name>" on the
            visitor, and call it with the same kw params.
 
            N)ÚAttributeErrorZvisit_unsupported_compilation)r-r.r/ÚmethÚerr©Úgetterr2r4r=ƒs
 &zAVisitable._generate_compiler_dispatch.<locals>._compiler_dispatch) r;r@r=r<Ú
isinstancer:rZInvalidRequestErrorr7ÚoperatorÚ
attrgetter)rDÚ
visit_nameÚnamer=r2rKr4rAos
 
 ÿ
þÿz%Visitable._generate_compiler_dispatch)Úkeyr0cCs|Sr1r2)rDrRr2r2r4Ú__class_getitem__•szVisitable.__class_getitem__)r7r8r9Ú__doc__Ú    __slots__Ú__annotations__Útypingrr=rCÚ classmethodrArSÚ __classcell__r2r2rEr4r'Os
%c@s¬eZdZdZdZdZdZdZdZdZ    dZ
d    Z d
Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)S)*r)a¯Defines visitor symbols used for internal traversal.
 
    The :class:`.InternalTraversal` class is used in two ways.  One is that
    it can serve as the superclass for an object that implements the
    various visit methods of the class.   The other is that the symbols
    themselves of :class:`.InternalTraversal` are used within
    the ``_traverse_internals`` collection.   Such as, the :class:`.Case`
    object defines ``_traverse_internals`` as ::
 
        _traverse_internals = [
            ("value", InternalTraversal.dp_clauseelement),
            ("whens", InternalTraversal.dp_clauseelement_tuples),
            ("else_", InternalTraversal.dp_clauseelement),
        ]
 
    Above, the :class:`.Case` class indicates its internal state as the
    attributes named ``value``, ``whens``, and ``else_``.    They each
    link to an :class:`.InternalTraversal` method which indicates the type
    of datastructure referred towards.
 
    Using the ``_traverse_internals`` structure, objects of type
    :class:`.InternalTraversible` will have the following methods automatically
    implemented:
 
    * :meth:`.HasTraverseInternals.get_children`
 
    * :meth:`.HasTraverseInternals._copy_internals`
 
    * :meth:`.HasCacheKey._gen_cache_key`
 
    Subclasses can also implement these methods directly, particularly for the
    :meth:`.HasTraverseInternals._copy_internals` method, when special steps
    are needed.
 
    .. versionadded:: 1.4
 
    ZHCZHLZCEZFCZCTSZCLZCTZEOZWCZCOÚSZSLÚANÚBÚOÚTZPDZDOZCDZMDZAKZPOZDDZPSZTHZSJZMEZSHZUKZDML_OVZDML_VZDML_MVZPAZIGZISÚMZMTZHTZILN)+r7r8r9rTZdp_has_cache_keyZdp_has_cache_key_listZdp_clauseelementZ)dp_fromclause_canonical_column_collectionZdp_clauseelement_tuplesZdp_clauseelement_listZdp_clauseelement_tupleZdp_executable_optionsZdp_with_context_optionsZdp_fromclause_ordered_setZ    dp_stringZdp_string_listZ dp_anon_nameZ
dp_booleanZ dp_operatorZdp_typeZ dp_plain_dictZdp_dialect_optionsZdp_string_clauseelement_dictZdp_string_multi_dictZdp_annotations_keyZ dp_plain_objZdp_named_ddl_elementZdp_prefix_sequenceZdp_table_hint_listZdp_setup_join_tupleZdp_memoized_select_entitiesZdp_statement_hint_listZdp_unknown_structureZdp_dml_ordered_valuesZ dp_dml_valuesZdp_dml_multi_valuesZdp_propagate_attrsZ    dp_ignoreZdp_inspectableZdp_multiZ dp_multi_listZdp_has_cache_key_tuplesZdp_inspectable_listr2r2r2r4r)šsR&        
c@sLeZdZUdZdZded<dZded<e d¡dd    œd
d d d œdd„ƒZ    dS)ÚHasTraverseInternalsaÀbase for classes that have a "traverse internals" element,
    which defines all kinds of ways of traversing the elements of an object.
 
    Compared to :class:`.Visitable`, which relies upon an external visitor to
    define how the object is travered (i.e. the :class:`.SQLCompiler`), the
    :class:`.HasTraverseInternals` interface allows classes to define their own
    traversal, that is, what attributes are accessed and in what order.
 
    r2Ú_TraverseInternalsTypeÚ_traverse_internalsFÚboolÚ _is_immutablezsqlalchemy.sql.traversals©Ú
omit_attrsúTuple[str, ...]rzIterable[HasTraverseInternals]©rfr/r0c sXtjj}z
|j}Wntk
r*gYSX|jj}tj     ‡‡fdd„|||dƒDƒ¡S)aäReturn immediate child :class:`.visitors.HasTraverseInternals`
        elements of this :class:`.visitors.HasTraverseInternals`.
 
        This is used for visit traversal.
 
        \**kw may contain flags that change the collection that is
        returned, for example to return a subset of items in order to
        cut down on larger traversals, or to return child items from a
        different context (such as schema-level collections instead of
        clause-level).
 
        c3s0|](\}}}|ˆkr|dk    r||fˆŽVqdSr1r2)Ú.0ÚattrnameÚobjrI©r/rfr2r4Ú    <genexpr>åsüz4HasTraverseInternals.get_children.<locals>.<genexpr>Z!_generated_get_children_traversal)
rZ    preloadedZsql_traversalsrbrHZ _get_childrenÚrun_generated_dispatchÚ    itertoolsÚchainÚ from_iterable)r-rfr/Z
traversalsZtraverse_internalsÚdispatchr2rlr4Ú get_childrenËs
 
ÿþz!HasTraverseInternals.get_childrenN)
r7r8r9rTrUrVrdrZpreload_modulersr2r2r2r4r`ºs
 
 ÿr`c@seZdZddddœdd„ZdS)Ú_InternalTraversalDispatchTypeÚobjectÚHasTraversalDispatchr©r-r.r0cCsdSr1r2)Úsr-r.r2r2r4r5ïsz'_InternalTraversalDispatchType.__call__Nr6r2r2r2r4rtîsrtc@sleZdZUdZdZiZded<dddœdd    „Zd
d d d dœdd„Zdd d ddœdd„Z    d d ddœdd„Z
dS)rvzcDefine infrastructure for classes that perform internal traversals
 
    .. versionadded:: 2.0
 
    r2z2ClassVar[Dict[Union[InternalTraversal, str], str]]Ú_dispatch_lookupr)zCallable[..., Any])Ú visit_symbolr0cCst|}t||dƒS)ztGiven a method from :class:`.HasTraversalDispatch`, return the
        corresponding method on a subclass.
 
        N)ryÚgetattr)r-rzrQr2r2r4rrþszHasTraversalDispatch.dispatchrurar:r)ÚtargetÚinternal_dispatchÚgenerate_dispatcher_namer0cCs@z|jj|}Wn$tk
r4| |j||¡}YnX|||ƒSr1)rFr@ÚKeyErrorÚgenerate_dispatch)r-r|r}r~Ú
dispatcherr2r2r4rnsÿ
z+HasTraversalDispatch.run_generated_dispatchz Type[object]rt)Ú
target_clsr}r~r0cCs| ||¡}t|||ƒ|Sr1)Ú_generate_dispatcherÚsetattr)r-r‚r}r~rr2r2r4r€s ÿ z&HasTraversalDispatch.generate_dispatch)r}Ú method_namer0c
Cszg}|D]0\}}| |¡}|dk    rt|}| ||f¡qdd dd„|Dƒ¡d}d||d}    ttt |    i|¡ƒS)Nz     return [
z, 
css |]\}}d|||fVqdS)z!        (%r, self.%s, visitor.%s)Nr2)rirjrPr2r2r4rm3sþÿz<HasTraversalDispatch._generate_dispatcher.<locals>.<genexpr>z
    ]
zdef %s(self, visitor):
Ú
)rrryÚappendÚjoinrrtrZ_exec_code_in_env)
r-r}r…ÚnamesrjZ    visit_symrIrPÚcodeZ    meth_textr2r2r4rƒ&s& 
 
ýþøÿ  þz)HasTraversalDispatch._generate_dispatcherN) r7r8r9rTrUryrVrrrnr€rƒr2r2r2r4rvós
  rvr>r?cCsTt}tD]F}|j}| d¡r| dd¡}|j}||ks>t|ƒ‚|||<||<qdS)NZdp_Úvisit_)ryr)rQÚ
startswithÚreplaceÚvalueÚAssertionError)ÚlookupÚsymrRZ    visit_keyZsym_namer2r2r4Ú_generate_traversal_dispatchEs
 r’c@sveZdZUdZejZded<ej    rJdddœdd„Z
dd    œd
d d d œdd„Z d ddœdd„Z dd    œd
d dd œdd„Z dS)ÚExternallyTraversibler2zMapping[Any, Any]Ú _annotationsrr)Úvaluesr0cCsdSr1r2)r-r•r2r2r4Ú    _annotate\szExternallyTraversible._annotaterergrúIterable[ExternallyTraversible]rhcKsdSr1r2©r-rfr/r2r2r4rs_sz"ExternallyTraversible.get_children)r/r0cKs
tƒ‚dS)zclone this elementN©ÚNotImplementedError)r-r/r2r2r4Ú_clonedszExternallyTraversible._cloner>cKs
tƒ‚dS)atReassign internal elements to be clones of themselves.
 
        Called during a copy-and-traverse operation on newly
        shallow-copied elements to create a deep copy.
 
        The given clone function should be used, which may be applying
        additional transformations to the element (i.e. replacement
        traversal, cloned traversal, annotations).
 
        Nr™r˜r2r2r4Ú_copy_internalshs z%ExternallyTraversible._copy_internalsN)r7r8r9rUrÚ
EMPTY_DICTr”rVrWrr–rsr›rœr2r2r2r4r“Us
ÿÿr“Ú_ET)ÚboundÚ_CEzColumnElement[Any]c@seZdZddddœdd„ZdS)Ú_CloneCallableTyperžr©Úelementr/r0cKsdSr1r2©r-r£r/r2r2r4r5€sz_CloneCallableType.__call__Nr6r2r2r2r4r¡sr¡c@seZdZddddœdd„ZdS)Ú_TraverseTransformCallableTyperžrz Optional[_ET]r¢cKsdSr1r2r¤r2r2r4r5…sz'_TraverseTransformCallableType.__call__Nr6r2r2r2r4r¥„sr¥Ú_ExtTc@s¶eZdZUdZdZiZded<ded<dddd    œd
d „Zd d dœdd„Ze    dddœdd„ƒZ
e    dddœdd„ƒZ
d d dœdd„Z
ddœdd„Z e ddœdd„ƒZ dddd œd!d"„Zd#S)$r(zÌBase class for visitor objects which can traverse externally using
    the :func:`.visitors.traverse` function.
 
    Direct usage of the :func:`.visitors.traverse` function is usually
    preferred.
 
    )Ú _visitor_dictÚ_nextzDict[str, Any]Ú__traverse_options__zOptional[ExternalTraversal]r¨r'r)rkr/r0cKs6|jD]*}t|d|jdƒ}|r||f|ŽSqdS)NrG)Úvisitor_iteratorr{r;)r-rkr/ÚvrIr2r2r4Útraverse_singlešs
z!ExternalTraversal.traverse_singleúOptional[ExternallyTraversible]úIterator[ExternallyTraversible]©rkr0cCs t||jƒS)zaTraverse the given expression structure, returning an iterator
        of all elements.
 
        )r"r©©r-rkr2r2r4r" szExternalTraversal.iterateú Literal[None]r>cCsdSr1r2r°r2r2r4r$©szExternalTraversal.traverser“cCsdSr1r2r°r2r2r4r$­scCst||j|jƒS©ú2Traverse and visit the given expression structure.)r$r©r§r°r2r2r4r$±sz%Dict[str, _TraverseCallableType[Any]]r?cCs6i}t|ƒD]$}| d¡r t||ƒ||dd…<q |S)Nr‹é)ÚdirrŒr{)r-ÚvisitorsrQr2r2r4Ú_memoized_attr__visitor_dict¸s
 
z.ExternalTraversal._memoized_attr__visitor_dictzIterator[ExternalTraversal]ccs |}|r|Vt|ddƒ}qdS)z8Iterate through this visitor and each 'chained' visitor.r¨N)r{)r-r«r2r2r4rªÂsz"ExternalTraversal.visitor_iteratorr¦rwcCst|jƒd}||_|S)z˜'Chain' an additional ExternalTraversal onto this ExternalTraversal
 
        The chained visitor will receive all visit events after this one.
 
        éÿÿÿÿ)Úlistrªr¨)r-r.Útailr2r2r4rpËszExternalTraversal.chainN)r7r8r9rTrUr©rVr¬r"rr$r·Úpropertyrªrpr2r2r2r4r(Œs
     
c@s\eZdZdZdZdddœdd„Zeddd    œd
d „ƒZed d d    œd d „ƒZddd    œdd „ZdS)ÚCloningExternalTraversalzÐBase class for visitor objects which can traverse using
    the :func:`.visitors.cloned_traverse` function.
 
    Direct usage of the :func:`.visitors.cloned_traverse` function is usually
    preferred.
 
 
    r2zList[ExternallyTraversible])Úlist_r0cs‡fdd„|DƒS)z`Apply cloned traversal to the given list of elements, and return
        the new list.
 
        csg|]}ˆ |¡‘qSr2)r$©riÚx©r-r2r4Ú
<listcomp>ész=CloningExternalTraversal.copy_and_process.<locals>.<listcomp>r2)r-r½r2rÀr4Úcopy_and_processâsz)CloningExternalTraversal.copy_and_processr±r>r¯cCsdSr1r2r°r2r2r4r$ësz!CloningExternalTraversal.traverser“cCsdSr1r2r°r2r2r4r$ïsr­cCst||j|jƒSr²)r%r©r§r°r2r2r4r$ós
ÿN)r7r8r9rTrUrÂrr$r2r2r2r4r¼Ös        r¼c@s\eZdZdZdZdddœdd„Zedd    d
œd d „ƒZeddd
œd d „ƒZddd
œdd „ZdS)ÚReplacingExternalTraversalzÙBase class for visitor objects which can traverse using
    the :func:`.visitors.replacement_traverse` function.
 
    Direct usage of the :func:`.visitors.replacement_traverse` function is
    usually preferred.
 
    r2r“r­)Úelemr0cCsdS)aReceive pre-copied elements during a cloning traversal.
 
        If the method returns a new element, the element is used
        instead of creating a simple copy of the element.  Traversal
        will halt on the newly returned element if it is re-encountered.
        Nr2)r-rÄr2r2r4rs    z"ReplacingExternalTraversal.replacer±r>r¯cCsdSr1r2r°r2r2r4r$sz#ReplacingExternalTraversal.traversecCsdSr1r2r°r2r2r4r$scs$ddddœ‡fdd„ }t|ˆj|ƒS)r³r“rr­r¢cs0ˆjD]$}tt|ƒ |¡}|dk    r|SqdSr1)rªrrÃr)r£r/r«ÚerÀr2r4r s
 
 
z4ReplacingExternalTraversal.traverse.<locals>.replace)r&r©)r-rkrr2rÀr4r$s N)r7r8r9rTrUrrr$r2r2r2r4rÃýs rÃr­zMapping[str, Any]r®)rkÚoptsr0ccsd|dkr dS|V|jf|Ž}|s&dSt|gƒ}|r`| ¡}|D]}|V| |jf|Ž¡q@q0dS)aHTraverse the given expression structure, returning an iterator.
 
    Traversal is configured to be breadth-first.
 
    The central API feature used by the :func:`.visitors.iterate`
    function is the
    :meth:`_expression.ClauseElement.get_children` method of
    :class:`_expression.ClauseElement` objects.  This method should return all
    the :class:`_expression.ClauseElement` objects which are associated with a
    particular :class:`_expression.ClauseElement` object. For example, a
    :class:`.Case` structure will refer to a series of
    :class:`_expression.ColumnElement` objects within its "whens" and "else\_"
    member variables.
 
    :param obj: :class:`_expression.ClauseElement` structure to be traversed
 
    :param opts: dictionary of iteration options.   This dictionary is usually
     empty in modern usage.
 
    N)rsrÚpopleftr‡)rkrÆÚchildrenÚstackZ
t_iteratorÚtr2r2r4r"6s 
r—r±z(Mapping[str, _TraverseCallableType[Any]])Úiteratorrkr¶r0cCsdSr1r2©rËrkr¶r2r2r4r#_scCsdSr1r2rÌr2r2r4r#hscCs(|D]}| |jd¡}|r||ƒq|S)aÅVisit the given expression structure using the given iterator of
    objects.
 
    :func:`.visitors.traverse_using` is usually called internally as the result
    of the :func:`.visitors.traverse` function.
 
    :param iterator: an iterable or sequence which will yield
     :class:`_expression.ClauseElement`
     structures; the iterator is assumed to be the
     product of the :func:`.visitors.iterate` function.
 
    :param obj: the :class:`_expression.ClauseElement`
     that was used as the target of the
     :func:`.iterate` function.
 
    :param visitors: dictionary of visit functions.  See :func:`.traverse`
     for details on this dictionary.
 
    .. seealso::
 
        :func:`.traverse`
 
 
    N)Úgetr;)rËrkr¶r|rIr2r2r4r#qs
 
)rkrÆr¶r0cCsdSr1r2©rkrÆr¶r2r2r4r$•scCsdSr1r2rÎr2r2r4r$žscCstt||ƒ||ƒS)aTraverse and visit the given expression structure using the default
    iterator.
 
     e.g.::
 
        from sqlalchemy.sql import visitors
 
        stmt = select(some_table).where(some_table.c.foo == 'bar')
 
        def visit_bindparam(bind_param):
            print("found bound value: %s" % bind_param.value)
 
        visitors.traverse(stmt, {}, {"bindparam": visit_bindparam})
 
    The iteration of objects uses the :func:`.visitors.iterate` function,
    which does a breadth-first traversal using a stack.
 
    :param obj: :class:`_expression.ClauseElement` structure to be traversed
 
    :param opts: dictionary of iteration options.   This dictionary is usually
     empty in modern usage.
 
    :param visitors: dictionary of visit functions.   The dictionary should
     have strings as keys, each of which would correspond to the
     ``__visit_name__`` of a particular kind of SQL expression object, and
     callable functions  as values, each of which represents a visitor function
     for that kind of object.
 
    )r#r"rÎr2r2r4r$§s"cCsdSr1r2rÎr2r2r4r%ÌscCsdSr1r2rÎr2r2r4r%Ùscsji‰tˆ dg¡ƒ‰dddœ‡‡fdd„ }ddddœ‡‡‡‡fdd    „ ‰|d
k    rbˆ|fd |iˆ—Ž}d
‰|S) aClone the given expression structure, allowing modifications by
    visitors for mutable objects.
 
    Traversal usage is the same as that of :func:`.visitors.traverse`.
    The visitor functions present in the ``visitors`` dictionary may also
    modify the internals of the given structure as the traversal proceeds.
 
    The :func:`.cloned_traverse` function does **not** provide objects that are
    part of the :class:`.Immutable` interface to the visit methods (this
    primarily includes :class:`.ColumnClause`, :class:`.Column`,
    :class:`.TableClause` and :class:`.Table` objects). As this traversal is
    only intended to allow in-place mutation of objects, :class:`.Immutable`
    objects are skipped. The :meth:`.Immutable._clone` method is still called
    on each object to allow for objects to replace themselves with a different
    object based on a clone of their sub-internals (e.g. a
    :class:`.ColumnClause` that clones its subquery to return a new
    :class:`.ColumnClause`).
 
    .. versionchanged:: 2.0  The :func:`.cloned_traverse` function omits
       objects that are part of the :class:`.Immutable` interface.
 
    The central API feature used by the :func:`.visitors.cloned_traverse`
    and :func:`.visitors.replacement_traverse` functions, in addition to the
    :meth:`_expression.ClauseElement.get_children`
    function that is used to achieve
    the iteration, is the :meth:`_expression.ClauseElement._copy_internals`
    method.
    For a :class:`_expression.ClauseElement`
    structure to support cloning and replacement
    traversals correctly, it needs to be able to pass a cloning function into
    its internal members in order to make copies of them.
 
    .. seealso::
 
        :func:`.visitors.traverse`
 
        :func:`.visitors.replacement_traverse`
 
    Ústop_onr“r¯cs t|ˆˆƒSr1)r%©rk)rÆr¶r2r4Údeferred_copy_internalssz0cloned_traverse.<locals>.deferred_copy_internalsr©rÄr/r0cs²|ˆkr |St|ƒˆkr¢d|krNttt|d|ƒƒ}|dk    rN|ˆt|ƒ<|S|jfdˆi|—Žˆt|ƒ<}|jfdˆi|—Ž|js¢ˆ |jd¡}|r¢||ƒˆt|ƒSdS)NrÚclone)    Úidrrr“r›rœrdrÍr;)rÄr/ÚnewelemrI)rÓÚclonedrÏr¶r2r4rÓs$ 
ÿ  zcloned_traverse.<locals>.cloneNrÑ)ÚsetrÍ)rkrÆr¶rÑr2)rÓrÖrÆrÏr¶r4r%âs-ÿÿÿz#_TraverseTransformCallableType[Any])rkrÆrr0cCsdSr1r2©rkrÆrr2r2r4r&>scCsdSr1r2rØr2r2r4r&GscCsdSr1r2rØr2r2r4r&Pscspi‰dd„ˆ dg¡Dƒ‰dddœ‡‡fdd„ }dddd    œ‡‡‡‡fd
d „ ‰|d k    rhˆ|fd |iˆ—Ž}d ‰|S)a]Clone the given expression structure, allowing element
    replacement by a given replacement function.
 
    This function is very similar to the :func:`.visitors.cloned_traverse`
    function, except instead of being passed a dictionary of visitors, all
    elements are unconditionally passed into the given replace function.
    The replace function then has the option to return an entirely new object
    which will replace the one given.  If it returns ``None``, then the object
    is kept in place.
 
    The difference in usage between :func:`.visitors.cloned_traverse` and
    :func:`.visitors.replacement_traverse` is that in the former case, an
    already-cloned object is passed to the visitor function, and the visitor
    function can then manipulate the internal state of the object.
    In the case of the latter, the visitor function should only return an
    entirely different object, or do nothing.
 
    The use case for :func:`.visitors.replacement_traverse` is that of
    replacing a FROM clause inside of a SQL structure with a different one,
    as is a common use case within the ORM.
 
    cSsh|] }t|ƒ’qSr2)rÔr¾r2r2r4Ú    <setcomp>vsz'replacement_traverse.<locals>.<setcomp>rÏr“r¯cs t|ˆˆƒSr1)r&rÐ)rÆrr2r4rÑxsz5replacement_traverse.<locals>.deferred_copy_internalsrrÒcs¨t|ƒˆksd|jkr|Sˆ|ƒ}|dk    r<ˆ t|ƒ¡|St|ƒ}|ˆkrœd|krt|d|ƒ}|dk    rt|ˆ|<|S|jf|Žˆ|<}|jfdˆi|—Žˆ|SdS)NZno_replacement_traverserrÓ)rÔr”Úaddr›rœ)rÄr/rÕZid_elem)rÓrÖrrÏr2r4rÓ}s&
ÿþ z#replacement_traverse.<locals>.cloneNrÑ)rÍ)rkrÆrrÑr2)rÓrÖrÆrrÏr4r&Ysÿÿÿ)NrTÚ
__future__rÚ collectionsrÚenumrrorNrWrrrrr    r
r r r rrrrrrrÚrrrZ util._has_cyrZ util.typingrrrÚ
annotationrÚelementsrZ_py_utilr r!r*Zsqlalchemy.cyextension.utilÚ__all__r+r'r)r:rar`rtrvZExtendedInternalTraversalr’ryr“ržr Z_TraverseCallableTyper¡r¥r¦Z MemoizedSlotsr(r¼rÃZ TraversibleZ ClauseVisitorZCloningVisitorZReplacingCloningVisitorrr"r#r$r%r&r2r2r2r4Ú<module>sÄ                               ÷ K4O #   J'2þ)$% \