��Qc@s�dZddlmZddlmZddlmZddlm Z m
Z
mZdZdej
fd��YZd �Zd
�Zd�ZdS(
s.Fixer for it.next() -> next(it), per PEP 3114.i(ttoken(tpython_symbols(t
fixer_base(tNametCalltfind_bindings;Calls to builtin next() possibly shadowed by global bindingtFixNextcBs,eZeZdZdZd�Zd�ZRS(s�
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* >
tprecCsWtt|�j||�td|�}|rJ|j|t�t|_n t|_dS(Nunext( tsuperRt
start_treeRtwarningtbind_warningtTruet
shadowed_nexttFalse(tselfttreetfilenametn((s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyR $scCs�|jd�}|jd�}|jd�}|r�|jr[|jtdd|j��qg|D]}|j�^qb}d|d_|jttdd|j�|��n�|r�tdd|j�}|j|�n�|rWt|�rA|d }d
jg|D]}t |�^q�j
�dkr=|j|t�ndS|jtd��n(d|kr|j|t�t
|_ndS(
Ntbasetattrtnameu__next__tprefixuiunexttheadtu__builtin__tglobal(tgetR
treplaceRRtcloneRtis_assign_targettjointstrtstripR
RR(RtnodetresultsRRRRR((s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyt transform.s,
(
4(t__name__t
__module__Rt
BM_compatibletPATTERNtorderR R#(((s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyRs
cCs]t|�}|dkrtSx:|jD]/}|jtjkrBtSt||�r&tSq&WtS(N( tfind_assigntNoneRtchildrenttypeRtEQUALt
is_subtreeR(R!tassigntchild((s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyRQscCsH|jtjkr|S|jtjks7|jdkr;dSt|j�S(N(R,tsymst expr_stmttsimple_stmttparentR*R)(R!((s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyR)]s
!cs-|�krtSt�fd�|jD��S(Nc3s|]}t|��VqdS(N(R.(t.0tc(R!(s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pys <genexpr>gs(RtanyR+(trootR!((R!s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyR.dsN(t__doc__tpgen2RtpygramRR1RRt
fixer_utilRRRRtBaseFixRRR)R.(((s,/sys/lib/python2.7/lib2to3/fixes/fix_next.pyt<module>s@
|