/opt/alt/python311/lib64/python3.11/lib2to3/__pycache__
NameSizeModeActions
btm_matcher.cpython-311.opt-1.pyc78140644editdlrm
btm_matcher.cpython-311.opt-2.pyc62640644editdlrm
btm_matcher.cpython-311.pyc78140644editdlrm
btm_utils.cpython-311.opt-1.pyc115300644editdlrm
btm_utils.cpython-311.opt-2.pyc100560644editdlrm
btm_utils.cpython-311.pyc115300644editdlrm
fixer_base.cpython-311.opt-1.pyc84310644editdlrm
fixer_base.cpython-311.opt-2.pyc57520644editdlrm
fixer_base.cpython-311.pyc84310644editdlrm
fixer_util.cpython-311.opt-1.pyc223810644editdlrm
fixer_util.cpython-311.opt-2.pyc203680644editdlrm
fixer_util.cpython-311.pyc223810644editdlrm
main.cpython-311.opt-1.pyc152200644editdlrm
main.cpython-311.opt-2.pyc134840644editdlrm
main.cpython-311.pyc152660644editdlrm
patcomp.cpython-311.opt-1.pyc102230644editdlrm
patcomp.cpython-311.opt-2.pyc97440644editdlrm
patcomp.cpython-311.pyc107250644editdlrm
pygram.cpython-311.opt-1.pyc20700644editdlrm
pygram.cpython-311.opt-2.pyc18730644editdlrm
pygram.cpython-311.pyc20700644editdlrm
pytree.cpython-311.opt-1.pyc352100644editdlrm
pytree.cpython-311.opt-2.pyc268610644editdlrm
pytree.cpython-311.pyc369930644editdlrm
refactor.cpython-311.opt-1.pyc384440644editdlrm
refactor.cpython-311.opt-2.pyc345390644editdlrm
refactor.cpython-311.pyc385260644editdlrm
__init__.cpython-311.opt-1.pyc3870644editdlrm
__init__.cpython-311.opt-2.pyc3870644editdlrm
__init__.cpython-311.pyc3870644editdlrm
__main__.cpython-311.opt-1.pyc3310644editdlrm
__main__.cpython-311.opt-2.pyc3310644editdlrm
__main__.cpython-311.pyc3310644editdlrm
Edit: /opt/alt/python311/lib64/python3.11/lib2to3/__pycache__/btm_matcher.cpython-311.pyc (7814B)
fdZdZddlZddlZddlmZddlmZddlm Z Gdd e Z Gd d e Z ia d ZdS) 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_treec6eZdZdZejZdZdS)BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcli|_g|_ttj|_d|_dS)N)transition_tablefixersnextrcountidcontentselfs :/opt/alt/python311/lib64/python3.11/lib2to3/btm_matcher.py__init__zBMNode.__init__s- " v|$$ N)__name__ __module__ __qualname____doc__ itertoolsrrrrrrs8II IO  Errc0eZdZdZdZdZdZdZdZdS) BottomMatcherzgThe main matcher class. After instantiating the patterns should be added using the add_fixer methodct|_t|_|jg|_g|_t jd|_dS)NRefactoringTool) setmatchrrootnodesr logging getLoggerloggerrs rrzBottomMatcher.__init__sAUU HH i[  '(9:: rc|j|t|j}|}|||j}|D]}|j|dS)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%s 5!!!5-..++--hhvTYh77 % , ,J   $ $U + + + + , ,rc |s|gSt|dtr\g}|dD]O}|||}|D]3}|||dd|4P|S|d|jvrt }||j|d<n|j|d}|ddr ||dd|}n|g}|S)z5Recursively adds a linear pattern to the AC automatonrr(rN) isinstancetupler-extendr r)rpatternr)r1 alternative end_nodesend next_nodes rr-zBottomMatcher.add1s& 7N gaj% ( ( K&qz C C !HH[H>> $CCC&&txx S'A'ABBBBC qz!777"HH 5>&wqz22"271:> qrr{ ( HHWQRR[ HBB &K  rc6|j}tt}|D]}|}|rd|_|jD]0}t |t jr|jdkr d|_n1|j dkr|j}n|j }||j vr3|j |}|j D]}|| |nV|j}|j |j jrnD||j vr2|j |}|j D]}|| ||j }||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.runSs )d### ;# ;D# "! ;/3 ,-6E!%55%+:L:L7<(4#(A--!1!7JJ!1!6J!AAA&5&Fz&RO!0!7@@--.>????@'+iO(/;,3?<"_%EEE*9*J:*V%4%;DDE#EN112BCCCC#3#: C#! ;Drcntdfd|jtddS)z %d [label=%s] //%sr)r keysprintr type_reprstrr r)node subnode_keysubnode print_nodes rrWz*BottomMatcher.print_ac..print_nodes#499;; $ $ / <0w Ik,B,BCDWDWXYZZZ!##'/*** 7####  $ $r}N)rQr")rrWs @rprint_aczBottomMatcher.print_acsM l $ $ $ $ $  49 c rN) rrrrrr3r-rMrYrrrrrsk++;;; , , ,   D666p     rrctsGddlm}|jD]'\}}t |t kr |t|<(t||S)Nr)python_symbols) _type_reprspygramr[__dict__itemsrDint setdefault)type_numr[namevals rrRrRsq 9******(06688 9 9ID#CyyCDS!1  ! !(H 5 55r)r __author__r$r collectionsrr r btm_utilsrobjectrrr\rRrrrrisGG; ######""""""V}}}}}F}}}@ 66666r