Files
PowerToys/PythonHome/Lib/lib2to3/fixes/fix_has_key.pyc

78 lines
3.1 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@sidZddlmZddlmZddlmZddlmZmZdej fd<00><00>YZ
dS( s&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.
i(tpytree(ttoken(t
fixer_base(tNamet parenthesizet FixHasKeycBseZeZdZd<00>ZRS(s<>
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
CsU|s t<00>|j}|jj|jkrC|jj|j<00>rCdS|jd<00>}|d}|j }g|dD]}|j
<00>^qp}|dj
<00>} |jd<00>}
|
r<>g|
D]}|j
<00>^q<>}
n| j|j |j|j |j |j|j|jfkrt| <00>} nt|<00>dkr6|d}ntj|j|<00>}d|_ td d
d<00>} |r<>td d
d<00>} tj|j| | f<00>} ntj|j | | |f<00>} |
r<>t| <00>} tj|j| ft|
<00><17>} n|jj|j |j|j|j|j|j|j|j|jf krHt| <00>} n|| _ | S( Ntnegationtanchortbeforetargtafteriiu uintprefixunot( tAssertionErrortsymstparentttypetnot_testtpatterntmatchtNonetgetR tclonet
comparisontand_testtor_testttesttlambdeftargumentRtlenRtNodetpowerRtcomp_opttupletexprtxor_exprtand_exprt
shift_exprt
arith_exprttermtfactor(tselftnodetresultsR RRR tnRR R
tn_optn_nottnew((s".\Lib\lib2to3\fixes\fix_has_key.pyt transformHsF  
 #"!   %   (t__name__t
__module__tTruet BM_compatibletPATTERNR/(((s".\Lib\lib2to3\fixes\fix_has_key.pyR'sN( t__doc__tRtpgen2RRt
fixer_utilRRtBaseFixR(((s".\Lib\lib2to3\fixes\fix_has_key.pyt<module>s