AlkantarClanX12
Current Path : /proc/self/root/usr/lib64/python3.8/lib2to3/fixes/__pycache__/ |
Current File : //proc/self/root/usr/lib64/python3.8/lib2to3/fixes/__pycache__/fix_xrange.cpython-38.opt-1.pyc |
U e5d� � @ 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��selfZtree�filename�� __class__� �0/usr/lib64/python3.8/lib2to3/fixes/fix_xrange.pyr s zFixXrange.start_treec C s d | _ d S 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�idr r r r r $ s zFixXrange.transform_xrangec C sf t |�| jkrb| �|�sbttd�|d �� g�}ttd�|g|jd�}|d D ]}|�|� qN|S d 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 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