3 \f @sndZddlmZddlmZddlmZddlm Z m Z m Z dZ Gdddej Zd d Zd d Zd dZdS)z.Fixer for it.next() -> next(it), per PEP 3114.)token)python_symbols) fixer_base)NameCall find_bindingz;Calls to builtin next() possibly shadowed by global bindingcs0eZdZdZdZdZfddZddZZS)FixNextTa power< base=any+ trailer< '.' attr='next' > trailer< '(' ')' > > | power< head=any+ trailer< '.' attr='next' > not trailer< '(' ')' > > | classdef< 'class' any+ ':' suite< any* funcdef< 'def' name='next' parameters< '(' NAME ')' > any+ > any* > > | global=global_stmt< 'global' any* 'next' any* > Zprecs>tt|j||td|}|r4|j|td|_nd|_dS)NnextTF)superr start_treerwarning bind_warning shadowed_next)selfZtreefilenamen) __class__ /usr/lib64/python3.6/fix_next.pyr $s   zFixNext.start_treecCs|st|jd}|jd}|jd}|rz|jrF|jtd|jdn2dd|D}d|d _|jttd |jd|n|rtd|jd}|j|nl|rt|r|d }djd d|Dj d kr|j |t dS|jtdnd|kr|j |t d|_dS)Nbaseattrname__next__)prefixcSsg|] }|jqSr)Zclone).0rrrr 9sz%FixNext.transform..r headcSsg|] }t|qSr)str)rrrrrrEsZ __builtin__globalT) AssertionErrorgetrreplacerrris_assign_targetjoinstripr r )rnoderesultsrrrrrrrr transform.s.        zFixNext.transform) __name__ __module__ __qualname__Z BM_compatibleZPATTERNorderr r) __classcell__rr)rrrs  rcCsFt|}|dkrdSx,|jD]"}|jtjkr0dSt||rdSqWdS)NFT) find_assignchildrentyperEQUAL is_subtree)r'ZassignZchildrrrr$Qs   r$cCs4|jtjkr|S|jtjks&|jdkr*dSt|jS)N)r1symsZ expr_stmtZ simple_stmtparentr/)r'rrrr/]s  r/cs$|kr dStfdd|jDS)NTc3s|]}t|VqdS)N)r3)rc)r'rr gszis_subtree..)anyr0)rootr'r)r'rr3dsr3N)__doc__Zpgen2rZpygramrr4rrZ fixer_utilrrrr ZBaseFixrr$r/r3rrrrs   @