Your IP : 216.73.216.64
U
e5d�@sJddlmZddlmZmZmZmZmZmZdZ dZ
Gdd�dej�ZdS)�)�
fixer_base)�Call�Comma�Name�Node� BlankLine�symsz0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)z(power< 'type' trailer< '(' x=any ')' > >csPeZdZdZdeeeefZ�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*
>
cs8tt|��|�}|r4d|kr4|d|dkr0|SdS|S)N�sortedZid1Zid2)�superr �match)�self�node�r�� __class__��0/usr/lib64/python3.8/lib2to3/fixes/fix_idioms.pyrOszFixIdioms.matchcCsHd|kr|�||�Sd|kr(|�||�Sd|kr<|�||�Std��dS)N�
isinstance�whiler
z
Invalid match)�transform_isinstance�transform_while�transform_sort�RuntimeError)r
r�resultsrrr� transformZszFixIdioms.transformcCsh|d��}|d��}d|_d|_ttd�|t�|g�}d|kr\d|_ttjtd�|g�}|j|_|S)N�x�T�� r�n�not)�clone�prefixrrrrrZnot_test)r
rrrrZtestrrrrdszFixIdioms.transform_isinstancecCs |d}|�td|jd��dS)Nr�True�r#)�replacerr#)r
rrZonerrrrpszFixIdioms.transform_whilecCs�|d}|d}|�d�}|�d�}|r>|�td|jd��n8|rn|��}d|_|�ttd�|g|jd��ntd��|��|j}d |kr�|r�|�d �d
|d
jf} d � | �|d
_n"t
�}
|j�|
�|�d �d
|
_dS)N�sort�next�list�exprr
r%rzshould not have reached here�
�)
�getr&rr#r"rr�remove�
rpartition�joinr�parentZappend_child)r
rrZ sort_stmtZ next_stmtZ list_callZsimple_expr�newZbtwnZprefix_linesZend_linerrrrts,
�
zFixIdioms.transform_sort)
�__name__�
__module__�__qualname__Zexplicit�TYPE�CMPZPATTERNrrrrr�
__classcell__rrrrr %s%
�'
r N)
rrZ
fixer_utilrrrrrrr7r6ZBaseFixr rrrr�<module>s
?>