/opt/alt/python37/lib64/python3.7/lib2to3/__pycache__
NameSizeModeActions
btm_matcher.cpython-37.opt-1.pyc48900644editdlrm
btm_matcher.cpython-37.opt-2.pyc33190644editdlrm
btm_matcher.cpython-37.pyc48900644editdlrm
btm_utils.cpython-37.opt-1.pyc61400644editdlrm
btm_utils.cpython-37.opt-2.pyc46200644editdlrm
btm_utils.cpython-37.pyc61400644editdlrm
fixer_base.cpython-37.opt-1.pyc62320644editdlrm
fixer_base.cpython-37.opt-2.pyc34710644editdlrm
fixer_base.cpython-37.pyc62320644editdlrm
fixer_util.cpython-37.opt-1.pyc120430644editdlrm
fixer_util.cpython-37.opt-2.pyc98750644editdlrm
fixer_util.cpython-37.pyc120430644editdlrm
main.cpython-37.opt-1.pyc85250644editdlrm
main.cpython-37.opt-2.pyc67700644editdlrm
main.cpython-37.pyc85590644editdlrm
patcomp.cpython-37.opt-1.pyc53660644editdlrm
patcomp.cpython-37.opt-2.pyc48560644editdlrm
patcomp.cpython-37.pyc56080644editdlrm
pygram.cpython-37.opt-1.pyc11950644editdlrm
pygram.cpython-37.opt-2.pyc9900644editdlrm
pygram.cpython-37.pyc11950644editdlrm
pytree.cpython-37.opt-1.pyc243230644editdlrm
pytree.cpython-37.opt-2.pyc149290644editdlrm
pytree.cpython-37.pyc250000644editdlrm
refactor.cpython-37.opt-1.pyc203290644editdlrm
refactor.cpython-37.opt-2.pyc162810644editdlrm
refactor.cpython-37.pyc203620644editdlrm
__init__.cpython-37.opt-1.pyc1400644editdlrm
__init__.cpython-37.opt-2.pyc1400644editdlrm
__init__.cpython-37.pyc1400644editdlrm
__main__.cpython-37.opt-1.pyc2240644editdlrm
__main__.cpython-37.opt-2.pyc2240644editdlrm
__main__.cpython-37.pyc2240644editdlrm
Edit: /opt/alt/python37/lib64/python3.7/lib2to3/__pycache__/btm_matcher.cpython-37.pyc (4890B)
B  f@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_tablefixersnextrcountidcontent)selfr8/opt/alt/python37/lib64/python3.7/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 getLoggerZlogger)rrrrrs  zBottomMatcher.__init__cCsL|j|t|j}|}|j||jd}x|D]}|j|q4WdS)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 reached)startN)r appendrZ pattern_treeZget_linear_subpatternaddr)rfixerZtreeZlinear match_nodesZ match_noderrr add_fixer%s    zBottomMatcher.add_fixerc Cs|s |gSt|dtrhg}xF|dD]:}|j||d}x&|D]}|||dd|q>Wq&W|S|d|jkrt}||j|d<n|j|d}|ddr|j|dd|d}n|g}|SdS)z5Recursively adds a linear pattern to the AC automatonr)rrN) isinstancetuplerextendrr)rpatternrr Z alternativeZ end_nodesendZ next_noderrrr1s" " zBottomMatcher.addc Cs|j}tt}x|D]}|}x|rd|_x,|jD]"}t|tjr0|jdkr0d|_Pq0W|j dkrh|j}n|j }||j kr|j |}xj|j D]}|| |qWnL|j}|j dk r|j jrP||j kr|j |}x|j D]}|| |qW|j }qWqW|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_nodeZchildZ node_tokenrrrrrunSs6          zBottomMatcher.runcs*tdfdd|jtddS)z %d [label=%s] //%sr)rkeysprintr type_reprstrr r )ZnodeZ subnode_keyZsubnode) print_noderrr1s  z*BottomMatcher.print_ac..print_node}N)r.r)rr)r1rprint_acs  zBottomMatcher.print_acN) rrrrrr!rr,r3rrrrrs  "8rcCsHtss