| Server IP : 162.144.4.212 / Your IP : 216.73.216.108 Web Server : Apache System : Linux gator2125.hostgator.com 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64 User : cozeellc ( 2980) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib64/python3.9/lib2to3/fixes/__pycache__/ |
Upload File : |
a
�i| � @ sB d Z ddlmZ ddlmZ ddlmZmZ G dd� dej�ZdS )a& Fixer for has_key().
Calls to .has_key() methods are expressed in terms of the 'in'
operator:
d.has_key(k) -> k in d
CAVEATS:
1) While the primary target of this fixer is dict.has_key(), the
fixer will change any has_key() method call, regardless of its
class.
2) Cases like this will not be converted:
m = d.has_key
if m(k):
...
Only *calls* to has_key() are converted. While it is possible to
convert the above to something like
m = d.__contains__
if m(k):
...
this is currently not done.
� )�pytree)�
fixer_base)�Name�parenthesizec @ s e Zd ZdZdZdd� ZdS )� FixHasKeyTa�
anchor=power<
before=any+
trailer< '.' 'has_key' >
trailer<
'('
( not(arglist | argument<any '=' any>) arg=any
| arglist<(not argument<any '=' any>) arg=any ','>
)
')'
>
after=any*
>
|
negation=not_test<
'not'
anchor=power<
before=any+
trailer< '.' 'has_key' >
trailer<
'('
( not(arglist | argument<any '=' any>) arg=any
| arglist<(not argument<any '=' any>) arg=any ','>
)
')'
>
>
>
c
C s� |sJ �| j }|jj|jkr.| j�|j�r.d S |�d�}|d }|j}dd� |d D �}|d �� }|�d�} | r�dd� | D �} |j|j |j|j
|j|j|j
|jfv r�t|�}t|�d kr�|d
}nt�|j|�}d|_tddd
�}
|�rtddd
�}t�|j||
f�}
t�|j ||
|f�}| �rBt|�}t�|j|ft| � �}|jj|j |j|j|j|j|j|j|j|jf v �r|t|�}||_|S )N�negation�anchorc S s g | ]}|� � �qS � ��clone��.0�nr r �1/usr/lib64/python3.9/lib2to3/fixes/fix_has_key.py�
<listcomp>R � z'FixHasKey.transform.<locals>.<listcomp>�before�arg�afterc S s g | ]}|� � �qS r r
r r r r r V r � � � �in)�prefix�not)�syms�parent�typeZnot_test�pattern�match�getr r Z
comparisonZand_testZor_test�testZlambdef�argumentr �lenr ZNodeZpowerr Zcomp_op�tuple�exprZxor_exprZand_exprZ
shift_exprZ
arith_exprZtermZfactor)
�selfZnode�resultsr r r r r r r Zn_opZn_not�newr r r � transformG sL �
�
�zFixHasKey.transformN)�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERNr) r r r r r &