관리-도구
편집 파일: fix_idioms.cpython-39.opt-2.pyc
a R�f � @ sJ d dl mZ d dlmZmZmZmZmZmZ dZ dZ G dd� dej�ZdS )� )� fixer_base)�Call�Comma�Name�Node� BlankLine�symsz0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)z(power< 'type' trailer< '(' x=any ')' > >c sP e Zd ZdZdeeeef Z� fdd�Zdd� Zdd� Z d d � Z dd� Z� ZS ) � FixIdiomsTa� isinstance=comparison< %s %s T=any > | isinstance=comparison< T=any %s %s > | while_stmt< 'while' while='1' ':' any+ > | sorted=any< any* simple_stmt< expr_stmt< id1=any '=' power< list='list' trailer< '(' (not arglist<any+>) any ')' > > > '\n' > sort= simple_stmt< power< id2=any trailer< '.' 'sort' > trailer< '(' ')' > > '\n' > next=any* > | sorted=any< any* simple_stmt< expr_stmt< id1=any '=' expr=any > '\n' > sort= simple_stmt< power< id2=any trailer< '.' 'sort' > trailer< '(' ')' > > '\n' > next=any* > c s8 t t| ��|�}|r4d|v r4|d |d kr0|S d S |S )N�sortedZid1Zid2)�superr �match)�self�node�r�� __class__� �=/opt/alt/python39/lib64/python3.9/lib2to3/fixes/fix_idioms.pyr O s zFixIdioms.matchc C sH d|v r| � ||�S d|v r(| �||�S d|v r<| �||�S td��d S )N� isinstance�whiler z Invalid match)�transform_isinstance�transform_while�transform_sort�RuntimeError)r r �resultsr r r � transformZ s zFixIdioms.transformc C sh |d � � }|d � � }d|_d|_ttd�|t� |g�}d|v r\d|_ttjtd�|g�}|j|_|S )N�x�T� � r �n�not)�clone�prefixr r r r r Znot_test)r r r r r �testr r r r d s zFixIdioms.transform_isinstancec C s |d }|� td|jd�� d S )Nr �True�r# )�replacer r# )r r r Zoner r r r p s zFixIdioms.transform_whilec C s� |d }|d }|� d�}|� d�}|r>|�td|jd�� n8|rn|�� }d|_|�ttd�|g|jd�� ntd��|�� |j}d |v r�|r�|�d �d |d jf} d � | �|d _n"t � } |j�| � |�d �d | _d S )N�sort�next�list�exprr r&