Ņō
$8Zc           @   s   d  Z  d d k l Z d d k l Z d d k l Z d d k l	 Z	 l
 Z
 l Z d Z d e i f d     YZ d	   Z d
   Z d   Z d S(   s.   Fixer for it.next() -> next(it), per PEP 3114.i   (   t   token(   t   python_symbols(   t
   fixer_base(   t   Namet   Callt   find_bindings;   Calls to builtin next() possibly shadowed by global bindingt   FixNextc           B   s&   e  Z d  Z d Z d   Z d   Z RS(   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* >
    t   prec         C   sY   t  t |   i | |  t d |  } | o |  i | t  t |  _ n
 t |  _ d  S(   Nu   next(	   t   superR   t
   start_treeR   t   warningt   bind_warningt   Truet   shadowed_nextt   False(   t   selft   treet   filenamet   n(    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyR	   #   s    c   
      C   sŊ  | p t   | i d  } | i d  } | i d  } | o |  i o  | i t d d | i  qŦg  } | D] } | | i   qw ~ } d | d _ | i t t d d | i |   nã | o& t d d | i } | i |  nķ | o t |  o` | d	 } d
 i	 g  }	 | D] } |	 t
 |  q%~	  i   d j o |  i | t  n d  S| i t d   n+ d | j o |  i | t  t |  _ n d  S(   Nt   baset   attrt   nameu   __next__t   prefixu    i    u   nextt   headt    u   __builtin__t   global(   t   AssertionErrort   getR   t   replaceR   R   t   cloneR   t   is_assign_targett   joint   strt   stripR
   R   R   (
   R   t   nodet   resultsR   R   R   t   _[1]R   R   t   _[2](    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyt	   transform-   s.    
 ')
=(   t   __name__t
   __module__t   PATTERNt   orderR	   R&   (    (    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyR      s   	
c         C   sc   t  |   } | d  j o t Sx> | i D]3 } | i t i j o t St | |   o t Sq( Wt S(   N(	   t   find_assignt   NoneR   t   childrent   typeR    t   EQUALt
   is_subtreeR   (   R"   t   assignt   child(    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyR   P   s    
 	c         C   sM   |  i  t i j o |  S|  i  t i j p |  i d  j o d  St |  i  S(   N(   R.   t   symst	   expr_stmtt   simple_stmtt   parentR,   R+   (   R"   (    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyR+   \   s
    #c            s/   |    j o t  St   f d   |  i D  S(   Nc         3   s"   x |  ] } t  |    Vq Wd  S(   N(   R0   (   t   .0t   c(   R"   (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pys	   <genexpr>f   s   	 (   R   t   anyR-   (   t   rootR"   (    (   R"   s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyR0   c   s    N(   t   __doc__t   pgen2R    t   pygramR   R3   R   R   t
   fixer_utilR   R   R   R   t   BaseFixR   R   R+   R0   (    (    (    s,   /usr/lib/python2.6/lib2to3/fixes/fix_next.pyt   <module>   s   ?		