Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/fix_has_key.cpython-35.pyc



��Yf��@sidZddlmZddlmZddlmZddlmZmZGdd�dej	�Z
dS)	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)�token)�
fixer_base)�Name�parenthesizec@s(eZdZdZdZdd�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

Cs.|st�|j}|jj|jkrC|jj|j�rCdS|jd�}|d}|j}dd�|dD�}|dj	�}|jd�}	|	r�dd�|	D�}	|j|j
|j|j|j|j
|j|jfkr�t|�}t|�d	kr|d
}ntj|j|�}d|_tdd
d�}
|r{tdd
d�}tj|j||
f�}
tj|j
||
|f�}|	r�t|�}tj|j|ft|	��}|jj|j
|j|j|j|j|j|j|j|jf	kr!t|�}||_|S)N�negation�anchorcSsg|]}|j��qS�)�clone)�.0�nr
r
�>/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_has_key.py�
<listcomp>Ss	z'FixHasKey.transform.<locals>.<listcomp>�before�arg�aftercSsg|]}|j��qSr
)r)rr
r
r
rrWs	��� �in�prefix�not)�AssertionError�syms�parent�typeZnot_test�pattern�match�getrrZ
comparisonZand_testZor_testZtestZlambdefZargumentr�lenrZNodeZpowerrZcomp_op�tuple�exprZxor_exprZand_exprZ
shift_exprZ
arith_exprZtermZfactor)
�selfZnodeZresultsrrr	rrrrZn_opZn_not�newr
r
r�	transformHsF	
	!
	"	zFixHasKey.transformN)�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERNr%r
r
r
rr'srN)�__doc__�rZpgen2rrZ
fixer_utilrrZBaseFixrr
r
r
r�<module>s


Hacked By AnonymousFox1.0, Coded By AnonymousFox