bg \ddlmZddlZddlmZddlmZerddlmZGddZ dS)) annotationsN) TYPE_CHECKING)_invalidate_cache)NodeNGcFeZdZdZdZddZdZdZddd Zddd Z d Z d S)TransformVisitoraPA visitor for handling transforms. The standard approach of using it is to call :meth:`~visit` with an *astroid* module and the class will take care of the rest, walking the tree and running the transforms for each encountered node. Based on its usage in AstroidManager.brain, it should not be reinstantiated. cBtjt|_dSN) collections defaultdictlist transforms)selfs c/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/astroid/transforms.py__init__zTransformVisitor.__init__s%1$77noderreturnc|j}|j|}|D]<\}}| ||r*||}|t|}|j|krn=|S)zdCall matching transforms for the given node if any and return the transformed node. ) __class__rr)rrclsrtransform_func predicaterets r _transformzTransformVisitor._transforms}n_S) )3   %NI IIdOO $nT**?%'''D=C''E rct|drF|jD]>}t||}||}||krt |||?||S)N_astroid_fields)hasattrrgetattr_visit_genericsetattrr)rrnamevaluevisiteds r_visitzTransformVisitor._visit2sy 4* + + 1, 1 1d++--e44e##D$000t$$$rct|trfd|DSt|trtfd|DS|rt|tr|S|S)Nc:g|]}|Sr .0childrs r z3TransformVisitor._visit_generic..=s'AAA5D''..AAArc3BK|]}|VdSr r)r*s r z2TransformVisitor._visit_generic..?s1FF,,U33FFFFFFr) isinstancer tuplestrr%)rrs` rr zTransformVisitor._visit_generic;s dD ! ! BAAAADAAA A dE " " GFFFFFFFFF F z$,, K{{4   rNNonecJ|j|||fdS)a7Register `transform(node)` function to be applied on the given astroid's `node_class` if `predicate` is None or returns true when called with the node as argument. The transform function may return a value which is then used to substitute the original node in the tree. N)rappendr node_class transformrs rregister_transformz#TransformVisitor.register_transformEs*  #**Iy+ABBBBBrcJ|j|||fdS)zUnregister the given transform.N)rremover6s runregister_transformz%TransformVisitor.unregister_transformOs(  #**Iy+ABBBBBrc,||S)zWalk the given astroid *tree* and transform each encountered node. Only the nodes which have transforms registered will actually be replaced or changed. )r%)rmodules rvisitzTransformVisitor.visitSs {{6"""r)rrrrr )rr3) __name__ __module__ __qualname____doc__rrr%r r9r<r?r(rrrrs888(%%%!!!CCCCCCCCCC#####rr) __future__rr typingrastroid.contextrastroidrrr(rrrHs #""""" ------I#I#I#I#I#I#I#I#I#I#r