0x1949 Team - FAZEMRX - MANAGER
Edit File: fix_idioms.cpython-310.pyc
o ��bc � @ sN d Z ddlmZ ddlmZmZmZmZmZm Z dZ dZG dd� dej�Z dS ) a� Adjust some old Python 2 idioms to their modern counterparts. * Change some type comparisons to isinstance() calls: type(x) == T -> isinstance(x, T) type(x) is T -> isinstance(x, T) type(x) != T -> not isinstance(x, T) type(x) is not T -> not isinstance(x, T) * Change "while 1:" into "while True:". * Change both v = list(EXPR) v.sort() foo(v) and the more general v = EXPR v.sort() foo(v) into v = sorted(EXPR) foo(v) � )� 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| ��|�}|rd|v r|d |d kr|S d S |S )N�sorted�id1�id2)�superr �match)�self�node�r�� __class__� �//usr/lib/python3.10/lib2to3/fixes/fix_idioms.pyr O s zFixIdioms.matchc C sD d|v r | � ||�S d|v r| �||�S d|v r| �||�S td��)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 �not_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 �oner r r r p s zFixIdioms.transform_whilec C s |d }|d }|� d�}|� d�}|r|�td|jd�� n|r7|�� }d|_|�ttd�|g|jd�� ntd��|�� |j}d |v r�|r^|�d �d |d jf} d � | �|d _d S |j scJ �|jd u sjJ �t� } |j � | � |j| u szJ �|�d �d | _d S d S )N�sort�next�list�exprr r) r zshould not have reached here� � )�getr* r r% r$ r r �remove� rpartition�join�parent�next_siblingr �append_child)r r r � sort_stmt� next_stmt� list_call�simple_expr�new�btwn�prefix_lines�end_liner r r r t s4 � �zFixIdioms.transform_sort) �__name__� __module__�__qualname__�explicit�TYPE�CMP�PATTERNr r r r r � __classcell__r r r r r % s %�' r N)�__doc__r r � fixer_utilr r r r r r rF rE �BaseFixr r r r r �<module> s