Viewing File: /opt/alt/python311/lib64/python3.11/lib2to3/fixes/__pycache__/fix_has_key.cpython-311.pyc



f|XdZddlmZddlmZddlmZmZGddejZdS)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parenthesizeceZdZdZdZdZdS)	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
R|sJ|j}|jj|jkr!|j|jrdS|d}|d}|j}d|dD}|d}|d}	|	rd|	D}	|j|j	|j|j
|j|j|j
|jfvrt|}t!|dkr	|d	}nt#j|j|}d
|_t)dd
}
|r-t)d
d
}t#j|j||
f}
t#j|j	||
|f}|	r:t|}t#j|j|ft-|	z}|jj|j	|j|j|j|j|j|j|j|jf	vrt|}||_|S)Nnegationanchorc6g|]}|Sclone.0ns  @/opt/alt/python311/lib64/python3.11/lib2to3/fixes/fix_has_key.py
<listcomp>z'FixHasKey.transform.<locals>.<listcomp>Rs 777!''))777beforeargafterc6g|]}|Sr
rrs  rrz'FixHasKey.transform.<locals>.<listcomp>Vs ...1QWWYY...r in)prefixnot)symsparenttypenot_testpatternmatchgetrr
comparisonand_testor_testtestlambdefargumentrlenrNodepowerrcomp_optupleexprxor_exprand_expr
shift_expr
arith_exprtermfactor)
selfnoderesultsr r
rrrrrn_opn_notnews
             r	transformzFixHasKey.transformGs#wyK
--Lt{++
.4;;z**"77WX%6777en""$$G$$	/.....E8
dit}NNNs##Cv;;!AYFF[V44F
D%%%	<s+++E;t|eT];;Dk$/Cv+>??	As##C+dj3&5<<*?@@C;DM $
t $ $TZ 999s##C

rN)__name__
__module____qualname__
BM_compatiblePATTERNr?r
rrrr&s/MG<&&&&&rrN)	__doc__rr
fixer_utilrrBaseFixrr
rr<module>rIs:++++++++GGGGG
"GGGGGr
Back to Directory File Manager