php IHDR w Q )Ba pHYs sRGB gAMA a IDATxMk\U s&uo,mD )Xw+e?tw.oWp;QHZnw`gaiJ9̟灙a=nl[ ʨ G;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ w@H;@ q$ y H@E7j 1j+OFRg}ܫ;@Ea~ j`u'o> j- $_q?qS XzG'ay
files >> /usr/lib/python2.6/lib2to3/fixes/ |
files >> //usr/lib/python2.6/lib2to3/fixes/fix_operator.py |
"""Fixer for operator.{isCallable,sequenceIncludes} operator.isCallable(obj) -> hasattr(obj, '__call__') operator.sequenceIncludes(obj) -> operator.contains(obj) """ # Local imports from .. import fixer_base from ..fixer_util import Call, Name, String class FixOperator(fixer_base.BaseFix): methods = "method=('isCallable'|'sequenceIncludes')" func = "'(' func=any ')'" PATTERN = """ power< module='operator' trailer< '.' %(methods)s > trailer< %(func)s > > | power< %(methods)s trailer< %(func)s > > """ % dict(methods=methods, func=func) def transform(self, node, results): method = results["method"][0] if method.value == u"sequenceIncludes": if "module" not in results: # operator may not be in scope, so we can't make a change. self.warning(node, "You should use operator.contains here.") else: method.value = u"contains" method.changed() elif method.value == u"isCallable": if "module" not in results: self.warning(node, "You should use hasattr(%s, '__call__') here." % results["func"].value) else: func = results["func"] args = [func.clone(), String(u", "), String(u"'__call__'")] return Call(Name(u"hasattr"), args, prefix=node.prefix)y~or5J={Eeu磝Qk ᯘG{?+]ן?wM3X^歌>{7پK>on\jy Rg/=fOroNVv~Y+ NGuÝHWyw[eQʨSb> >}Gmx[o[<{Ϯ_qFvM IENDB`