Your IP : 18.191.116.61
�
j f�
� @ s_ d Z d d l m Z d d l m Z m Z m Z d d l m Z Gd d � d e j � Z d S)z/Fixer that changes xrange(...) into range(...).� )�
fixer_base)�Name�Call�consuming_calls)�patcompc s� e Z d Z d Z d Z � f d d � Z d d � Z d d � Z d d
� Z d d � Z d
Z
e j e
� Z
d Z e j e � Z d d � Z � S)� FixXrangeTz�
power<
(name='range'|name='xrange') trailer< '(' args=any ')' >
rest=any* >
c s) t t | � j | | � t � | _ d S)N)�superr �
start_tree�set�transformed_xranges)�self�tree�filename)� __class__� �=/opt/alt/python34/lib64/python3.4/lib2to3/fixes/fix_xrange.pyr s zFixXrange.start_treec C s
d | _ d S)N)r )r r
r r r r �finish_tree s zFixXrange.finish_treec C s^ | d } | j d k r) | j | | � S| j d k rH | j | | � St t | � � � d S)N�nameZxrange�range)�value�transform_xrange�transform_range�
ValueError�repr)r �node�resultsr r r r � transform s
zFixXrange.transformc C s@ | d } | j t d d | j �� | j j t | � � d S)Nr r �prefix)�replacer r r �add�id)r r r r r r r r $ s
zFixXrange.transform_xrangec C s� t | � | j k r� | j | � r� t t d � | d j � g � } t t d � | g d | j �} x | d D] } | j | � qs W| Sd S)Nr �args�listr �rest)r r �in_special_contextr r Zcloner Zappend_child)r r r Z
range_callZ list_call�nr r r r * s "zFixXrange.transform_rangez3power< func=NAME trailer< '(' node=any ')' > any* >z�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� | j d k r d Si } | j j d k rg | j j | j j | � rg | d | k rg | d j t k S| j j | j | � o� | d | k S)NFr �func)�parent�p1�matchr r �p2)r r r r r r r$ ? s zFixXrange.in_special_context)�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERNr r r r r ZP1r Zcompile_patternr( ZP2r* r$ r r )r r r s r N)
�__doc__� r Z
fixer_utilr r r r ZBaseFixr r r r r �<module> s