Ñò
$8Zc           @   s_   d  Z  d d k l Z d d k l Z l Z l Z d d k l Z d e i f d „  ƒ  YZ	 d S(   s/   Fixer that changes xrange(...) into range(...).i   (   t
   fixer_base(   t   Namet   Callt   consuming_calls(   t   patcompt	   FixXrangec           B   sn   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z e	 i
 e ƒ Z d Z e	 i
 e ƒ Z d „  Z RS(	   sˆ   
              power<
                 (name='range'|name='xrange') trailer< '(' args=any ')' >
              rest=any* >
              c         C   s)   t  t |  ƒ i | | ƒ t ƒ  |  _ d  S(   N(   t   superR   t
   start_treet   sett   transformed_xranges(   t   selft   treet   filename(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyR      s    c         C   s   d  |  _ d  S(   N(   t   NoneR	   (   R
   R   R   (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyt   finish_tree   s    c         C   sb   | d } | i  d j o |  i | | ƒ S| i  d j o |  i | | ƒ St t | ƒ ƒ ‚ d  S(   Nt   nameu   xrangeu   range(   t   valuet   transform_xranget   transform_ranget
   ValueErrort   repr(   R
   t   nodet   resultsR   (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyt	   transform   s    
c         C   s@   | d } | i  t d d | i ƒƒ |  i i t | ƒ ƒ d  S(   NR   u   ranget   prefix(   t   replaceR   R   R	   t   addt   id(   R
   R   R   R   (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyR   $   s    
c         C   s•   t  | ƒ |  i j o{ |  i | ƒ oj t t d ƒ | d i ƒ  g ƒ } t t d ƒ | g d | i ƒ} x | d D] } | i | ƒ qu W| Sd  S(   Nu   ranget   argsu   listR   t   rest(   R   R	   t   in_special_contextR   R   t   cloneR   t   append_child(   R
   R   R   t
   range_callt	   list_callt   n(    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyR   *   s    " s3   power< func=NAME trailer< '(' node=any ')' > any* >sŸ   for_stmt< 'for' any 'in' node=any ':' any* >
            | comp_for< 'for' any 'in' node=any any* >
            | comparison< any 'in' node=any any*>
         c         C   s”   | i  d  j o t Sh  } | i  i  d  j	 o? |  i i | i  i  | ƒ o# | d | j o | d i t j S|  i i | i  | ƒ o | d | j S(   NR   t   func(   t   parentR   t   Falset   p1t   matchR   R   t   p2(   R
   R   R   (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyR   ?   s    (   t   __name__t
   __module__t   PATTERNR   R   R   R   R   t   P1R   t   compile_patternR'   t   P2R)   R   (    (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyR      s   						N(
   t   __doc__t    R    t
   fixer_utilR   R   R   R   t   BaseFixR   (    (    (    s.   /usr/lib/python2.6/lib2to3/fixes/fix_xrange.pyt   <module>   s   