HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: //lib/python3.10/lib2to3/fixes/__pycache__/fix_idioms.cpython-310.pyc
o

��bc�@sNdZddlmZddlmZmZmZmZmZm	Z	dZ
dZGdd�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 ')' > >csPeZdZdZdeeeefZ�fdd�Zdd�Zdd�Z	d	d
�Z
dd�Z�ZS)
�	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|��|�}|rd|vr|d|dkr|SdS|S)N�sorted�id1�id2)�superr	�match)�self�node�r��	__class__��//usr/lib/python3.10/lib2to3/fixes/fix_idioms.pyrOszFixIdioms.matchcCsDd|vr
|�||�Sd|vr|�||�Sd|vr|�||�Std��)N�
isinstance�whiler
z
Invalid match)�transform_isinstance�transform_while�transform_sort�RuntimeError)rr�resultsrrr�	transformZszFixIdioms.transformcCsh|d��}|d��}d|_d|_ttd�|t�|g�}d|vr.d|_ttjtd�|g�}|j|_|S)N�x�T�� r�n�not)�clone�prefixrrrrr�not_test)rrrrr�testrrrrdszFixIdioms.transform_isinstancecCs |d}|�td|jd��dS)Nr�True�r%)�replacerr%)rrr�onerrrrpszFixIdioms.transform_whilecCs|d}|d}|�d�}|�d�}|r|�td|jd��n|r7|��}d|_|�ttd�|g|jd��ntd��|��|j}d	|vr�|r^|�d	�d
|d
jf}	d	�	|	�|d
_dS|j
scJ�|jdusjJ�t�}
|j
�
|
�|j|
uszJ�|�d	�d
|
_dSdS)N�sort�next�list�exprr
r)r zshould not have reached here�
�)�getr*rr%r$rr�remove�
rpartition�join�parent�next_siblingr�append_child)rrr�	sort_stmt�	next_stmt�	list_call�simple_expr�new�btwn�prefix_lines�end_linerrrrts4


�
�zFixIdioms.transform_sort)
�__name__�
__module__�__qualname__�explicit�TYPE�CMP�PATTERNrrrrr�
__classcell__rrrrr	%s
%�'
r	N)�__doc__r r�
fixer_utilrrrrrrrFrE�BaseFixr	rrrr�<module>s