:tJ$dZddlZddlmZejrddlZGddejZ GddZ Gd d e Z dS) zVAPI for traversing the AST nodes. Implemented by the compiler and meta introspection. N)NodecDeZdZdedejdejdejfdZdS) VisitCallablenodeargskwargsreturncdSNselfrrr s /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/jinja2/visitor.py__call__zVisitCallable.__call__ s CN)__name__ __module__ __qualname__rtAnyrr rrrr sJ  ae qu       rrceZdZdZdeddfdZdedejdejdejfdZdedejdejdejfd Z d S) NodeVisitoraWalks the abstract syntax tree and call visitor functions for every node found. The visitor functions may return values which will be forwarded by the `visit` method. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `get_visitor` function. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. rr zt.Optional[VisitCallable]cNt|dt|jdS)zReturn the visitor function for this node or `None` if no visitor exists for this node. In that case the generic visit function is used instead. visit_N)getattrtyper)rrs r get_visitorzNodeVisitor.get_visitors( t;d4jj&9;;TBBBrrr cj||}| ||g|Ri|S|j|g|Ri|S)z Visit a node.)r generic_visit)rrrr fs rvisitzNodeVisitor.visit#s]   T " " =1T+D+++F++ +!t!$8888888rcV|D]}|j|g|Ri|dS)z9Called if no explicit visitor function exists for a node.N)iter_child_nodesr"rs rr zNodeVisitor.generic_visit,sL))++ . .D DJt -d - - -f - - - - . .rN) rrr__doc__rrrrr"r r rrrrs  CC)DCCCC9$9qu99!%9999.$.qu..!%......rrc eZdZdZdedejdejdefdZdedejdejdejefdZ dS) NodeTransformeraWalks the abstract syntax tree and allows modifications of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor functions to replace or remove the old node. If the return value of the visitor function is `None` the node will be removed from the previous location otherwise it's replaced with the return value. The return value may be the original node in which case no replacement takes place. rrr r c|D]\}}t|trxg}|D]k}t|tr?|j|g|Ri|}|+t|ts||V||l||dd<t|tr5|j|g|Ri|}|t||t||||Sr ) iter_fields isinstancelistrr"extendappenddelattrsetattr) rrrr field old_value new_valuesvaluenew_nodes rr zNodeTransformer.generic_visit=s6 $ 0 0 2 2 3 3 E9)T** 3 &--E!%..% * 5 B4 B B B6 B B =$!+E4!8!8%&--e444$%%e,,,,) !!! It,, 3%4:iA$AAA&AA#D%((((D%222 rcX|j|g|Ri|}t|ts|gS|S)z{As transformers may return lists in some places this method can be used to enforce a list as return value. )r"r*r+)rrrr rvs r visit_listzNodeTransformer.visit_listSsCTZ .t . . .v . ."d## 4K rN) rrrr%rrrr Listr7r rrr'r'2s$qu$, t AE QU qvd|      rr') r%typingrnodesr TYPE_CHECKINGtyping_extensionsteProtocolrrr'r rrr?s?""""  ........D*****k*****r