관리-도구
편집 파일: fix_xrange.cpython-310.opt-1.pyc
o 6��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��selfZtree�filename�� __class__� �?/opt/alt/python310/lib64/python3.10/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 s@ |d }|j dkr| �||�S |j dkr| �||�S tt|���)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 sj t |�| jvr1| �|�s3ttd�|d �� g�}ttd�|g|jd�}|d D ]}|�|� q'|S d 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 u rdS i }|j j d ur%| j�|j j |�r%|d |u r%|d jtv S | j�|j |�o2|d |u 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( � __classcell__r r r r r s r N) �__doc__� r Z fixer_utilr r r r ZBaseFixr r r r r �<module> s