/opt/alt/python35/lib64/python3.5/lib2to3/__pycache__
NameSizeModeActions
btm_matcher.cpython-35.opt-1.pyc53160644editdlrm
btm_matcher.cpython-35.opt-2.pyc37310644editdlrm
btm_matcher.cpython-35.pyc53160644editdlrm
btm_utils.cpython-35.opt-1.pyc67860644editdlrm
btm_utils.cpython-35.opt-2.pyc52540644editdlrm
btm_utils.cpython-35.pyc67860644editdlrm
fixer_base.cpython-35.opt-1.pyc65030644editdlrm
fixer_base.cpython-35.opt-2.pyc37280644editdlrm
fixer_base.cpython-35.pyc65030644editdlrm
fixer_util.cpython-35.opt-1.pyc133520644editdlrm
fixer_util.cpython-35.opt-2.pyc111740644editdlrm
fixer_util.cpython-35.pyc133520644editdlrm
main.cpython-35.opt-1.pyc91390644editdlrm
main.cpython-35.opt-2.pyc73720644editdlrm
main.cpython-35.pyc91780644editdlrm
patcomp.cpython-35.opt-1.pyc60350644editdlrm
patcomp.cpython-35.opt-2.pyc55150644editdlrm
patcomp.cpython-35.pyc63320644editdlrm
pygram.cpython-35.opt-1.pyc12590644editdlrm
pygram.cpython-35.opt-2.pyc10440644editdlrm
pygram.cpython-35.pyc12590644editdlrm
pytree.cpython-35.opt-1.pyc260050644editdlrm
pytree.cpython-35.opt-2.pyc165910644editdlrm
pytree.cpython-35.pyc268690644editdlrm
refactor.cpython-35.opt-1.pyc227610644editdlrm
refactor.cpython-35.opt-2.pyc187010644editdlrm
refactor.cpython-35.pyc228030644editdlrm
__init__.cpython-35.opt-1.pyc1360644editdlrm
__init__.cpython-35.opt-2.pyc1280644editdlrm
__init__.cpython-35.pyc1360644editdlrm
__main__.cpython-35.opt-1.pyc2330644editdlrm
__main__.cpython-35.opt-2.pyc2250644editdlrm
__main__.cpython-35.pyc2330644editdlrm
Edit: /opt/alt/python35/lib64/python3.5/lib2to3/__pycache__/btm_matcher.cpython-35.pyc (5316B)
 yzf@sdZdZddlZddlZddlmZddlmZddlm 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.eZdZdZejZddZdS)BMNodez?Class for a node of the Aho-Corasick automaton used in matchingcCs1i|_g|_ttj|_d|_dS)N)transition_tablefixersnextrcountidcontent)selfr8/opt/alt/python35/lib64/python3.5/lib2to3/btm_matcher.py__init__s  zBMNode.__init__N)__name__ __module__ __qualname____doc__ itertoolsr rrrrrrs  rc@sReZdZdZddZddZddZdd Zd d Zd S) BottomMatcherzgThe main matcher class. After instantiating the patterns should be added using the add_fixer methodcCsFt|_t|_|jg|_g|_tjd|_dS)NZRefactoringTool) setmatchrrootZnodesr loggingZ getLoggerZlogger)rrrrrs    zBottomMatcher.__init__cCsh|jj|t|j}|j}|j|d|j}x|D]}|jj|qJWdS)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_fixercCs |s |gSt|dtrg}x[|dD]O}|j|d|}x1|D])}|j|j|dd|qSWq1W|S|d|jkrt}||j|d|j D]3}||jkrdg||<||j |qBW|j }q+WqW|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 rparentkeys) rZleavesZcurrent_ac_nodeZresultsZleafZcurrent_ast_nodeZchildZ node_tokenrrrrrunSs>     !          zBottomMatcher.runcs7tdfdd|jtddS)z %d [label=%s] //%sr)rr,printr 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   " =rcCsbtsRddlm}x9|jjD](\}}t|tkr&|t|s