ó u®žQc@sidZddlmZddlmZddlmZddlmZmZdej fd„ƒ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„ZRS(s• anchor=power< before=any+ trailer< '.' 'has_key' > trailer< '(' ( not(arglist | argument) arg=any ','> ) ')' > after=any* > | negation=not_test< 'not' anchor=power< before=any+ trailer< '.' 'has_key' > trailer< '(' ( not(arglist | argument) arg=any ','> ) ')' > > > c CsI|j}|jj|jkr7|jj|jƒr7dS|jdƒ}|d}|j}g|dD]}|j ƒ^qd}|dj ƒ} |jdƒ} | rÃg| D]}|j ƒ^qš} n| j|j |j|j |j |j |j|jfkr t| ƒ} nt|ƒdkr*|d}ntj|j|ƒ}d|_td d dƒ} |rtd d dƒ} tj|j| | fƒ} ntj|j | | |fƒ} | råt| ƒ} tj|j| ft| ƒƒ} n|jj|j |j|j|j|j|j|j|j|jf kr<t| ƒ} n|| _| S( Ntnegationtanchortbeforetargtafteriiu uintprefixunot(tsymstparentttypetnot_testtpatterntmatchtNonetgetR tclonet comparisontand_testtor_testttesttlambdeftargumentRtlenRtNodetpowerRtcomp_opttupletexprtxor_exprtand_exprt shift_exprt arith_exprttermtfactor(tselftnodetresultsR RRR tnRR R tn_optn_nottnew((s//sys/lib/python2.7/lib2to3/fixes/fix_has_key.pyt transformHsD   #"!   %   (t__name__t __module__tTruet BM_compatibletPATTERNR.(((s//sys/lib/python2.7/lib2to3/fixes/fix_has_key.pyR'sN( t__doc__tRtpgen2RRt fixer_utilRRtBaseFixR(((s//sys/lib/python2.7/lib2to3/fixes/fix_has_key.pyts