Viewing File: /opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/fix_next.cpython-35.pyc



¯ÕYffã@s™dZddlmZddlmZddlmZddlm	Z	m
Z
mZdZGdd„dej
ƒZd	d
„Zdd„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/python35/lib64/python3.5/lib2to3/fixes/fix_next.pyr$szFixNext.start_treecCsq|st‚|jdƒ}|jdƒ}|jdƒ}|r¯|jrg|jtdd|jƒƒqmdd„|Dƒ}d|d	_|jttd
d|jƒ|ƒƒn¾|rÚtdd|jƒ}|j|ƒn“|rHt|ƒr2|d}djdd„|Dƒƒj	ƒd
kr.|j
|tƒdS|jtdƒƒn%d|krm|j
|tƒd|_dS)NÚbaseÚattrÚnameÚ__next__ÚprefixcSsg|]}|jƒ‘qSr)Zclone)Ú.0rrrrú
<listcomp>9s	z%FixNext.transform.<locals>.<listcomp>Úér	ÚheadcSsg|]}t|ƒ‘qSr)Ústr)rrrrrrEs	Z__builtin__ÚglobalT)ÚAssertionErrorÚgetrÚreplacerrrÚis_assign_targetÚjoinÚstriprr
)rÚnodeZresultsrrrrrrrrÚ	transform.s.	
(
(zFixNext.transform)Ú__name__Ú
__module__Ú__qualname__Z
BM_compatibleZPATTERNÚorderrr(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_stmtZsimple_stmtÚparentr-)r'rrrr-]s
!r-cs0|ˆkrdSt‡fdd†|jDƒƒS)NTc3s|]}t|ˆƒVqdS)N)r1)rÚc)r'rrú	<genexpr>gszis_subtree.<locals>.<genexpr>)Úanyr.)Úrootr'r)r'rr1dsr1N)Ú__doc__Zpgen2rZpygramrr2rrZ
fixer_utilrrrr
ZBaseFixrr$r-r1rrrrÚ<module>s@
Back to Directory File Manager