AlkantarClanX12
Current Path : /opt/alt/python37/lib64/python3.7/lib2to3/fixes/__pycache__/ |
Current File : //opt/alt/python37/lib64/python3.7/lib2to3/fixes/__pycache__/fix_xrange.cpython-37.opt-1.pyc |
B � f� � @ sF d Z ddlmZ ddlmZmZmZ ddlmZ G dd� dej�Z dS )z/Fixer that changes xrange(...) into range(...).� )� fixer_base)�Name�Call�consuming_calls)�patcompc sh e Zd ZdZdZ� fdd�Zdd� Zdd� Zd d � Zdd� Z d Z e�e �Z dZe�e�Zdd� Z� ZS )� FixXrangeTz� power< (name='range'|name='xrange') trailer< '(' args=any ')' > rest=any* > c s t t| ��||� t� | _d S )N)�superr � start_tree�set�transformed_xranges)�self�tree�filename)� __class__� �=/opt/alt/python37/lib64/python3.7/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 sD |d }|j dkr| �||�S |j dkr4| �||�S tt|���d S )N�nameZxrange�range)�value�transform_xrange�transform_range� ValueError�repr)r �node�resultsr r r r � transform s zFixXrange.transformc C s0 |d }|� td|jd�� | 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 sj t |�| jkrf| �|�sfttd�|d �� g�}ttd�|g|jd�}x|d D ]}|�|� qPW |S d S )Nr �args�list)r �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 sf |j d krdS i }|j j d k rJ| j�|j j |�rJ|d |krJ|d jtkS | j�|j |�od|d |kS )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$ � __classcell__r r )r r r s r N) �__doc__� r Z fixer_utilr r r r ZBaseFixr r r r r �<module> s