/opt/alt/python39/lib64/python3.9/lib2to3/__pycache__
NameSizeModeActions
btm_matcher.cpython-39.opt-1.pyc48900644editdlrm
btm_matcher.cpython-39.opt-2.pyc33190644editdlrm
btm_matcher.cpython-39.pyc48900644editdlrm
btm_utils.cpython-39.opt-1.pyc61610644editdlrm
btm_utils.cpython-39.opt-2.pyc46490644editdlrm
btm_utils.cpython-39.pyc61610644editdlrm
fixer_base.cpython-39.opt-1.pyc62680644editdlrm
fixer_base.cpython-39.opt-2.pyc35170644editdlrm
fixer_base.cpython-39.pyc62680644editdlrm
fixer_util.cpython-39.opt-1.pyc121830644editdlrm
fixer_util.cpython-39.opt-2.pyc100200644editdlrm
fixer_util.cpython-39.pyc121830644editdlrm
main.cpython-39.opt-1.pyc86840644editdlrm
main.cpython-39.opt-2.pyc69310644editdlrm
main.cpython-39.pyc87020644editdlrm
patcomp.cpython-39.opt-1.pyc54020644editdlrm
patcomp.cpython-39.opt-2.pyc48940644editdlrm
patcomp.cpython-39.pyc56180644editdlrm
pygram.cpython-39.opt-1.pyc12750644editdlrm
pygram.cpython-39.opt-2.pyc10700644editdlrm
pygram.cpython-39.pyc12750644editdlrm
pytree.cpython-39.opt-1.pyc236850644editdlrm
pytree.cpython-39.opt-2.pyc149820644editdlrm
pytree.cpython-39.pyc243080644editdlrm
refactor.cpython-39.opt-1.pyc206260644editdlrm
refactor.cpython-39.opt-2.pyc165800644editdlrm
refactor.cpython-39.pyc206560644editdlrm
__init__.cpython-39.opt-1.pyc3150644editdlrm
__init__.cpython-39.opt-2.pyc3150644editdlrm
__init__.cpython-39.pyc3150644editdlrm
__main__.cpython-39.opt-1.pyc2280644editdlrm
__main__.cpython-39.opt-2.pyc2280644editdlrm
__main__.cpython-39.pyc2280644editdlrm
Edit: /opt/alt/python39/lib64/python3.9/lib2to3/__pycache__/btm_matcher.cpython-39.pyc (4890B)
a XC?h@sldZdZddlZddlZddlmZddlmZddlm Z Gdd d e Z Gd d d e Z ia d 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_treec@s eZdZdZeZddZdS)BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcCs"i|_g|_ttj|_d|_dS)N)transition_tablefixersnextrcountidcontentselfr8/opt/alt/python39/lib64/python3.9/lib2to3/btm_matcher.py__init__s zBMNode.__init__N)__name__ __module__ __qualname____doc__ itertoolsr rrrrrrsrc@s8eZdZdZddZddZddZdd Zd d Zd S) BottomMatcherzgThe main matcher class. After instantiating the patterns should be added using the add_fixer methodcCs0t|_t|_|jg|_g|_td|_dS)NZRefactoringTool) setmatchrrootZnodesr loggingZ getLoggerZloggerrrrrrs  zBottomMatcher.__init__cCsH|j|t|j}|}|j||jd}|D]}|j|q2dS)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 appendrZ pattern_treeZget_linear_subpatternaddr)rfixerZtreeZlinear match_nodesZ match_noderrr add_fixer%s   zBottomMatcher.add_fixerc Cs|s |gSt|dtr`g}|dD]6}|j||d}|D]}|||dd|q:q$|S|d|jvrt}||j|d<n|j|d}|ddr|j|dd|d}n|g}|SdS)z5Recursively adds a linear pattern to the AC automatonrrrN) isinstancetupler extendrr)rpatternrr"Z alternativeZ end_nodesendZ next_noderrrr 1s"  zBottomMatcher.addc Cs|j}tt}|D]}|}|rd|_|jD]$}t|tjr*|jdkr*d|_qPq*|j dkrb|j}n|j }||j vr|j |}|j D]}|| |qnH|j}|j dur|j jrq||j vr|j |}|j D]}|| |q|j }qq|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;FrN)rrlistZ was_checkedZchildrenr$rZLeafvaluetyperr rparent) rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodechildZ node_tokenr!rrrrunSs8          zBottomMatcher.runcs*tdfdd|jtddS)z %d [label=%s] //%sr)rkeysprintr type_reprstrr r )ZnodeZ subnode_keyZsubnode print_noderrr5s  z*BottomMatcher.print_ac..print_node}N)r1rrrr4rprint_acs  zBottomMatcher.print_acN) rrrrrr#r r/r7rrrrrs  "8rcCsDts8ddlm}|jD]\}}t|tkr|t|<qt||S)Nr)python_symbols) _type_reprsZpygramr8__dict__itemsr,int setdefault)Ztype_numr8namevalrrrr2s  r2)r __author__rr collectionsrrrZ btm_utilsrobjectrrr9r2rrrrs