pfc@sdZddlmZddlmZddlmZddlm Z m Z m Z dZ dej fdYZd Zd Zd Zd S( s.Fixer for it.next() -> next(it), per PEP 3114.i(ttoken(tpython_symbols(t fixer_base(tNametCallt find_bindings;Calls to builtin next() possibly shadowed by global bindingtFixNextcBs,eZeZdZdZdZdZRS(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|tt|_n t|_dS(Nunext( tsuperRt start_treeRtwarningt bind_warningtTruet shadowed_nexttFalse(tselfttreetfilenametn((s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyR $s  cCs|jd}|jd}|jd}|r|jr[|jtdd|jqg|D]}|j^qb}d|d_|jttdd|j|n|rtdd|j}|j|n|rWt|rA|d }d jg|D]}t |^qj d kr=|j |t ndS|jtdn(d |kr|j |t t |_ndS( Ntbasetattrtnameu__next__tprefixuiunexttheadtu __builtin__tglobal(tgetR treplaceRRtcloneRtis_assign_targettjointstrtstripR R R (RtnodetresultsRRRRR((s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyt transform.s,  (  4 (t__name__t __module__R t BM_compatibletPATTERNtorderR R#(((s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyRs  cCs]t|}|dkrtSx:|jD]/}|jtjkrBtSt||r&tSq&WtS(N( t find_assigntNoneRtchildrenttypeRtEQUALt is_subtreeR (R!tassigntchild((s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyRQs  cCsH|jtjkr|S|jtjks7|jdkr;dSt|jS(N(R,tsymst expr_stmtt simple_stmttparentR*R)(R!((s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyR)]s !cs-|krtStfd|jDS(Nc3s|]}t|VqdS(N(R.(t.0tc(R!(s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pys gs(R tanyR+(trootR!((R!s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyR.ds N(t__doc__tpgen2RtpygramRR1RRt fixer_utilRRRR tBaseFixRRR)R.(((s./usr/lib64/python2.7/lib2to3/fixes/fix_next.pyts@