ž zyMa– c@sidZddlmZddlmZddlmZddlmZmZGdd„dej ƒZ dS( u&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(upytree(utoken(u fixer_base(uNameu parenthesizecBs,|EeZdZdZdZdd„ZdS(u FixHasKeyu• 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 Cs=|s t‚|j}|jj|jkrC|jj|jƒrCdS|jdƒ}|d}|j }dd„|dDƒ}|dj ƒ}|jdƒ} | r·dd„| Dƒ} n|j|j |j|j |j |j|j|jfkrÿt|ƒ}nt|ƒd kr|d }ntj|j|ƒ}d |_ td d d ƒ} |r„tdd d ƒ} tj|j| | fƒ} ntj|j || |fƒ} | rÙt| ƒ} tj|j| ft| ƒƒ} n|jj|j |j|j|j|j|j|j|j|jf kr0t| ƒ} n|| _ | S(NunegationuanchorcSsg|]}|jƒ‘qS((uclone(u.0un((u>/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_has_key.pyu Ss u'FixHasKey.transform..ubeforeuarguaftercSsg|]}|jƒ‘qS((uclone(u.0un((u>/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_has_key.pyu Ws iiu uinuprefixunot( uAssertionErrorusymsuparentutypeunot_testupatternumatchuNoneugetuprefixucloneu comparisonuand_testuor_testutestulambdefuargumentu parenthesizeulenupytreeuNodeupoweruNameucomp_oputupleuexpruxor_expruand_expru shift_expru arith_exprutermufactor( uselfunodeuresultsusymsunegationuanchoruprefixubeforeuarguafterun_opun_notunew((u>/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_has_key.pyu transformHsF    !   %   uFixHasKey.transformNT(u__name__u __module__u __qualname__uTrueu BM_compatibleuPATTERNu transform(u __locals__((u>/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_has_key.pyu FixHasKey'su FixHasKeyN( u__doc__uupytreeupgen2utokenu fixer_baseu fixer_utiluNameu parenthesizeuBaseFixu FixHasKey(((u>/opt/alt/python33/lib64/python3.3/lib2to3/fixes/fix_has_key.pyus