Ñò
mÈKc           @   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   ?		