î i ff ã@s™dZddlmZddlmZddlmZddlm Z m Z m Z dZ Gdd„dej ƒZd d „Zd d „Zd d„ZdS)z.Fixer for it.next() -> next(it), per PEP 3114.é)Útoken)Úpython_symbols)Ú fixer_base)ÚNameÚCallÚ find_bindingz;Calls to builtin next() possibly shadowed by global bindingcs@eZdZdZdZdZ‡fdd†Zdd„Z‡S)Ú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* > ZprecsWtt|ƒj||ƒtd|ƒ}|rJ|j|tƒd|_n d|_dS)NÚnextTF)ÚsuperrÚ start_treerÚwarningÚ bind_warningÚ shadowed_next)ÚselfZtreeÚfilenameÚn)Ú __class__©ú;/opt/alt/python34/lib64/python3.4/lib2to3/fixes/fix_next.pyr $s  zFixNext.start_treecCsk|jdƒ}|jdƒ}|jdƒ}|r£|jr[|jtdd|jƒƒqgdd„|Dƒ}d|d _|jttd d|jƒ|ƒƒnÄ|rÎtdd|jƒ}|j|ƒn™|r?t|ƒr)|d }djd d„|Dƒƒjƒd kr%|j |t ƒndS|jtdƒƒn(d|krg|j |t ƒd|_ndS)NÚbaseÚattrÚnameÚ__next__ÚprefixcSsg|]}|jƒ‘qSr)Zclone)Ú.0rrrrú 9s z%FixNext.transform..Úér ÚheadcSsg|]}t|ƒ‘qSr)Ústr)rrrrrrEs Z __builtin__ÚglobalT) ÚgetrÚreplacerrrÚis_assign_targetÚjoinÚstripr r )rÚnodeZresultsrrrrrrrrÚ transform.s,  (  ( zFixNext.transform)Ú__name__Ú __module__Ú __qualname__Z BM_compatibleZPATTERNZorderr r'rr)rrrs  rcCs]t|ƒ}|dkrdSx:|jD]/}|jtjkrBdSt||ƒr&dSq&WdS)NFT)Ú find_assignÚchildrenÚtyperÚEQUALÚ is_subtree)r&ZassignZchildrrrr#Qs  r#cCsH|jtjkr|S|jtjks7|jdkr;dSt|jƒS)N)r-ÚsymsZ expr_stmtZ simple_stmtÚparentr+)r&rrrr+]s !r+cs0|ˆkrdSt‡fdd†|jDƒƒS)NTc3s|]}t|ˆƒVqdS)N)r/)rÚc)r&rrú gszis_subtree..)Úanyr,)Úrootr&r)r&rr/ds r/N)Ú__doc__Zpgen2rZpygramrr0rrZ fixer_utilrrrr ZBaseFixrr#r+r/rrrrÚs@