/usr/lib64/python3.12/lib2to3/__pycache__
NameSizeModeActions
btm_matcher.cpython-312.opt-1.pyc73200644editdlrm
btm_matcher.cpython-312.opt-2.pyc57840644editdlrm
btm_matcher.cpython-312.pyc73200644editdlrm
btm_utils.cpython-312.opt-1.pyc110860644editdlrm
btm_utils.cpython-312.opt-2.pyc96200644editdlrm
btm_utils.cpython-312.pyc110860644editdlrm
fixer_base.cpython-312.opt-1.pyc78710644editdlrm
fixer_base.cpython-312.opt-2.pyc52030644editdlrm
fixer_base.cpython-312.pyc78710644editdlrm
fixer_util.cpython-312.opt-1.pyc217920644editdlrm
fixer_util.cpython-312.opt-2.pyc197840644editdlrm
fixer_util.cpython-312.pyc217920644editdlrm
main.cpython-312.opt-1.pyc140080644editdlrm
main.cpython-312.opt-2.pyc122820644editdlrm
main.cpython-312.pyc140620644editdlrm
patcomp.cpython-312.opt-1.pyc94100644editdlrm
patcomp.cpython-312.opt-2.pyc89360644editdlrm
patcomp.cpython-312.pyc99720644editdlrm
pygram.cpython-312.opt-1.pyc18940644editdlrm
pygram.cpython-312.opt-2.pyc17000644editdlrm
pygram.cpython-312.pyc18940644editdlrm
pytree.cpython-312.opt-1.pyc331840644editdlrm
pytree.cpython-312.opt-2.pyc248610644editdlrm
pytree.cpython-312.pyc346960644editdlrm
refactor.cpython-312.opt-1.pyc342550644editdlrm
refactor.cpython-312.opt-2.pyc303600644editdlrm
refactor.cpython-312.pyc343230644editdlrm
__init__.cpython-312.opt-1.pyc3460644editdlrm
__init__.cpython-312.opt-2.pyc3460644editdlrm
__init__.cpython-312.pyc3460644editdlrm
__main__.cpython-312.opt-1.pyc2770644editdlrm
__main__.cpython-312.opt-2.pyc2770644editdlrm
__main__.cpython-312.pyc2770644editdlrm
Edit: /usr/lib64/python3.12/lib2to3/__pycache__/btm_matcher.cpython-312.pyc (7320B)
{|jvdZdZddlZddlZddlmZddlmZddlm Z Gdd e Z Gd d e Z ia d Zy) aA bottom-up tree matching algorithm implementation meant to speed up 2to3's matching process. After the tree patterns are reduced to their rarest linear path, a linear Aho-Corasick automaton is created. The linear automaton traverses the linear paths from the leaves to the root of the AST and returns a set of nodes for further matching. This reduces significantly the number of candidate nodes.z+George Boutsioukis N) defaultdict)pytree) reduce_treec8eZdZdZej ZdZy)BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcji|_g|_ttj|_d|_y)N)transition_tablefixersnextrcountidcontentselfs ,/usr/lib64/python3.12/lib2to3/btm_matcher.py__init__zBMNode.__init__s( " v||$ N)__name__ __module__ __qualname____doc__ itertoolsrrrrrrsI IOO Errc.eZdZdZdZdZdZdZdZy) BottomMatcherzgThe main matcher class. After instantiating the patterns should be added using the add_fixer methodct|_t|_|jg|_g|_t jd|_y)NRefactoringTool) setmatchrrootnodesr logging getLoggerloggerrs rrzBottomMatcher.__init__s;U H ii[  ''(9: rc|jj|t|j}|j }|j ||j }|D]}|jj|y)zReduces a fixer's pattern tree to a linear path and adds it to the matcher(a common Aho-Corasick automaton). The fixer is appended on the matching states and called when they are reachedstartN)r appendr pattern_treeget_linear_subpatternaddr")rfixertreelinear match_nodes match_nodes r add_fixerzBottomMatcher.add_fixer%sh 5!5--.++-hhvTYYh7 %J    $ $U +&rc |s|gSt|dtrLg}|dD]@}|j||}|D]&}|j|j|dd|(B|S|d|jvrt }||j|d<n|j|d}|ddr|j|dd|}|S|g}|S)z5Recursively adds a linear pattern to the AC automatonrr(rN) isinstancetupler-extendr r)rpatternr)r1 alternative end_nodesend next_nodes rr-zBottomMatcher.add1s7N gaj% (K&qz !HH[H> $C&&txx S'AB% *  qz!7!77"H 5>&&wqz2"2271:> qr{ HHWQR[ HB  'K  rc|j}tt}|D]?}|}|s d|_|jD]5}t |t js|jdk(s.d|_n|jdk(r |j}n |j}||jvr5|j|}|jD]}||j|nq|j}|j|jjr||jvr4|j|}|jD]}||j||j}|r7B|S)auThe main interface with the bottom matcher. The tree is traversed from the bottom using the constructed automaton. Nodes are only checked once as the tree is retraversed. When the automaton fails, we give it one more shot(in case the above tree matches as a whole with the rejected leaf), then we break for the next leaf. There is the special case of multiple arguments(see code comments) where we recheck the nodes Args: The leaves of the AST tree to be matched Returns: A dictionary of node matches with fixers as the keys T;Fr)r"rlist was_checkedchildrenr5rLeafvaluetyper r r*parent) rleavescurrent_ac_noderesultsleafcurrent_ast_nodechild node_tokenr.s rrunzBottomMatcher.runSsW ))d#D# "/3 ,-66E!%5%++:L7<(4 7 $((A-!1!7!7J!1!6!6J!A!AA&5&F&Fz&RO!0!7!7--.>?"8'+iiO(//;,33??"_%E%EE*9*J*J:*V%4%;%;E#EN112BC&<$4#:#: C#Hrc`tdfd|jtdy)z %d [label=%s] //%sr)r keysprintr type_reprstrr r)node subnode_keysubnode print_nodes rrWz*BottomMatcher.print_ac..print_nodes|#4499; // <0ww Ik,BCDWXYZ!#'//*7# risHG; #"V}F}@ 6r