Ticket #5688: haskey-tested.patch

File haskey-tested.patch, 20.7 KB (added by Vladimir Perić, 5 years ago)
  • twisted/application/service.py

    diff --git twisted/application/service.py twisted/application/service.py
    index d4a13dc..66fef85 100644
    class Service: 
    169169
    170170    def __getstate__(self):
    171171        dict = self.__dict__.copy()
    172         if dict.has_key("running"):
     172        if "running" in dict:
    173173            del dict['running']
    174174        return dict
    175175
    class MultiService(Service): 
    298298
    299299    def addService(self, service):
    300300        if service.name is not None:
    301             if self.namedServices.has_key(service.name):
     301            if service.name in self.namedServices:
    302302                raise RuntimeError("cannot have two services with same name"
    303303                                   " '%s'" % service.name)
    304304            self.namedServices[service.name] = service
  • twisted/conch/unix.py

    diff --git twisted/conch/unix.py twisted/conch/unix.py
    index ffeb7ad..3a44be0 100644
    class SFTPServerForUnixConchUser: 
    303303        NOTE: this function assumes it runs as the logged-in user:
    304304        i.e. under _runAsUser()
    305305        """
    306         if attrs.has_key("uid") and attrs.has_key("gid"):
     306        if "uid" in attrs and "gid" in attrs:
    307307            os.chown(path, attrs["uid"], attrs["gid"])
    308         if attrs.has_key("permissions"):
     308        if "permissions" in attrs:
    309309            os.chmod(path, attrs["permissions"])
    310         if attrs.has_key("atime") and attrs.has_key("mtime"):
     310        if "atime" in attrs and "mtime" in attrs:
    311311            os.utime(path, (attrs["atime"], attrs["mtime"]))
    312312
    313313    def _getAttrs(self, s):
    class UnixSFTPFile: 
    399399            openFlags |= os.O_TRUNC
    400400        if flags & FXF_EXCL == FXF_EXCL:
    401401            openFlags |= os.O_EXCL
    402         if attrs.has_key("permissions"):
     402        if "permissions" in attrs:
    403403            mode = attrs["permissions"]
    404404            del attrs["permissions"]
    405405        else:
  • twisted/enterprise/adbapi.py

    diff --git twisted/enterprise/adbapi.py twisted/enterprise/adbapi.py
    index a361a20..0531d2d 100644
    class ConnectionPool: 
    218218
    219219        for arg in self.CP_ARGS:
    220220            cp_arg = 'cp_%s' % arg
    221             if connkw.has_key(cp_arg):
     221            if cp_arg in connkw:
    222222                setattr(self, arg, connkw[cp_arg])
    223223                del connkw[cp_arg]
    224224
  • twisted/mail/imap4.py

    diff --git twisted/mail/imap4.py twisted/mail/imap4.py
    index 6ca8384..bf36eee 100644
    class MemoryAccount(object): 
    46654665    ##
    46664666    def addMailbox(self, name, mbox = None):
    46674667        name = name.upper()
    4668         if self.mailboxes.has_key(name):
     4668        if name in self.mailboxes:
    46694669            raise MailboxCollision, name
    46704670        if mbox is None:
    46714671            mbox = self._emptyMailbox(name, self.allocateID())
    class MemoryAccount(object): 
    47154715    def rename(self, oldname, newname):
    47164716        oldname = oldname.upper()
    47174717        newname = newname.upper()
    4718         if not self.mailboxes.has_key(oldname):
     4718        if oldname not in self.mailboxes:
    47194719            raise NoSuchMailbox, oldname
    47204720
    47214721        inferiors = self._inferiorNames(oldname)
    47224722        inferiors = [(o, o.replace(oldname, newname, 1)) for o in inferiors]
    47234723
    47244724        for (old, new) in inferiors:
    4725             if self.mailboxes.has_key(new):
     4725            if new in self.mailboxes:
    47264726                raise MailboxCollision, new
    47274727
    47284728        for (old, new) in inferiors:
  • twisted/manhole/explorer.py

    diff --git twisted/manhole/explorer.py twisted/manhole/explorer.py
    index 428b3e2..30db8e2 100644
    False=not True 
    2929class Pool(UserDict.UserDict):
    3030    def getExplorer(self, object, identifier):
    3131        oid = id(object)
    32         if self.data.has_key(oid):
     32        if oid in self.data:
    3333            # XXX: This potentially returns something with
    3434            # 'identifier' set to a different value.
    3535            return self.data[oid]
  • twisted/manhole/service.py

    diff --git twisted/manhole/service.py twisted/manhole/service.py
    index 332bc81..c9d4679 100644
    class Perspective(pb.Avatar): 
    255255        compatMessage = None
    256256        for client in clients:
    257257            try:
    258                 if not client.capabilities.has_key("Failure"):
     258                if "Failure" not in client.capabilities:
    259259                    if compatMessage is None:
    260260                        compatMessage = origMessage[:]
    261261                        for i in xrange(len(message)):
  • twisted/names/cache.py

    diff --git twisted/names/cache.py twisted/names/cache.py
    index 973a3d9..ab00a41 100644
    class CacheResolver(common.ResolverBase): 
    9797
    9898        self.cache[query] = (cacheTime or self._reactor.seconds(), payload)
    9999
    100         if self.cancel.has_key(query):
     100        if query in self.cancel:
    101101            self.cancel[query].cancel()
    102102
    103103        s = list(payload[0]) + list(payload[1]) + list(payload[2])
  • twisted/news/database.py

    diff --git twisted/news/database.py twisted/news/database.py
    index 1ba1694..137736a 100644
    class Article: 
    6363
    6464    def getHeader(self, header):
    6565        h = header.lower()
    66         if self.headers.has_key(h):
     66        if h in self.headers:
    6767            return self.headers[h][1]
    6868        else:
    6969            return ''
    class PickleStorage(_ModerationMixin): 
    350350            return self.notifyModerators(moderators, a)
    351351
    352352        for group in groups:
    353             if self.db.has_key(group):
     353            if group in self.db:
    354354                if len(self.db[group].keys()):
    355355                    index = max(self.db[group].keys()) + 1
    356356                else:
    class PickleStorage(_ModerationMixin): 
    469469
    470470
    471471    def load(self, filename, groups = None, moderators = ()):
    472         if PickleStorage.sharedDBs.has_key(filename):
     472        if filename in PickleStorage.sharedDBs:
    473473            self.db = PickleStorage.sharedDBs[filename]
    474474        else:
    475475            try:
    class NewsShelf(_ModerationMixin): 
    646646            high = self.dbm['groups'][group].maxArticle
    647647        r = []
    648648        for i in range(low, high + 1):
    649             if self.dbm['groups'][group].articles.has_key(i):
     649            if i in self.dbm['groups'][group].articles:
    650650                r.append((i, self.dbm['groups'][group].articles[i].getHeader(header)))
    651651        return defer.succeed(r)
    652652
  • twisted/persisted/aot.py

    diff --git twisted/persisted/aot.py twisted/persisted/aot.py
    index 59fde57..f4ad975 100644
    def unjellyFromSource(stringOrFile): 
    260260    else:
    261261        exec stringOrFile in ns
    262262
    263     if ns.has_key('app'):
     263    if 'app' in ns:
    264264        return unjellyFromAOT(ns['app'])
    265265    else:
    266266        raise ValueError("%s needs to define an 'app', it didn't!" % stringOrFile)
    class AOTJellier: 
    504504#mutable inside one. The Ref() class will only print the "Ref(..)" around an
    505505#object if it has a Reference explicitly attached.
    506506
    507             if self.prepared.has_key(id(obj)):
     507            if id(obj) in self.prepared:
    508508                oldRef = self.prepared[id(obj)]
    509509                if oldRef.refnum:
    510510                    # it's been referenced already
    class AOTJellier: 
    538538                    state = self.jellyToAO(obj.__dict__)
    539539                retval.setObj(Instance(reflect.qual(obj.__class__), state))
    540540
    541             elif copy_reg.dispatch_table.has_key(objType):
     541            elif objType in copy_reg.dispatch_table:
    542542                unpickleFunc, state = copy_reg.dispatch_table[objType](obj)
    543543
    544544                retval.setObj(Copyreg( reflect.fullFuncName(unpickleFunc),
  • twisted/persisted/styles.py

    diff --git twisted/persisted/styles.py twisted/persisted/styles.py
    index 81c8c30..e3ca39b 100644
    def pickleModule(module): 
    6868
    6969def unpickleModule(name):
    7070    'support function for copy_reg to unpickle module refs'
    71     if oldModules.has_key(name):
     71    if name in oldModules:
    7272        log.msg("Module has moved: %s" % name)
    7373        name = oldModules[name]
    7474        log.msg(name)
    class Versioned: 
    202202        bases.reverse()
    203203        bases.append(self.__class__) # don't forget me!!
    204204        for base in bases:
    205             if base.__dict__.has_key('persistenceForgets'):
     205            if 'persistenceForgets' in base.__dict__:
    206206                for slot in base.persistenceForgets:
    207                     if dct.has_key(slot):
     207                    if slot in dct:
    208208                        del dct[slot]
    209             if base.__dict__.has_key('persistenceVersion'):
     209            if 'persistenceVersion' in base.__dict__:
    210210                dct['%s.persistenceVersion' % reflect.qual(base)] = base.persistenceVersion
    211211        return dct
    212212
    class Versioned: 
    219219        bases.reverse()
    220220        bases.append(self.__class__) # don't forget me!!
    221221        # first let's look for old-skool versioned's
    222         if self.__dict__.has_key("persistenceVersion"):
     222        if "persistenceVersion" in self.__dict__:
    223223
    224224            # Hacky heuristic: if more than one class subclasses Versioned,
    225225            # we'll assume that the higher version number wins for the older
    class Versioned: 
    244244        for base in bases:
    245245            # ugly hack, but it's what the user expects, really
    246246            if (Versioned not in base.__bases__ and
    247                 not base.__dict__.has_key('persistenceVersion')):
     247                'persistenceVersion' not in base.__dict__):
    248248                continue
    249249            currentVers = base.persistenceVersion
    250250            pverName = '%s.persistenceVersion' % reflect.qual(base)
  • twisted/protocols/sip.py

    diff --git twisted/protocols/sip.py twisted/protocols/sip.py
    index 58f5e8b..c1e7ab9 100644
    class InMemoryRegistry: 
    12891289    def getAddress(self, userURI):
    12901290        if userURI.host != self.domain:
    12911291            return defer.fail(LookupError("unknown domain"))
    1292         if self.users.has_key(userURI.username):
     1292        if userURI.username in self.users:
    12931293            dc, url = self.users[userURI.username]
    12941294            return defer.succeed(url)
    12951295        else:
    class InMemoryRegistry: 
    13211321        if logicalURL.host != self.domain:
    13221322            log.msg("Registration for domain we don't handle.")
    13231323            return defer.fail(RegistrationError(404))
    1324         if self.users.has_key(logicalURL.username):
     1324        if logicalURL.username in self.users:
    13251325            dc, old = self.users[logicalURL.username]
    13261326            dc.reset(3600)
    13271327        else:
  • twisted/python/components.py

    diff --git twisted/python/components.py twisted/python/components.py
    index 72f15cd..6fb1f2a 100644
    class Componentized(styles.Versioned): 
    282282        True on your adapter class.
    283283        """
    284284        k = reflect.qual(interface)
    285         if self._adapterCache.has_key(k):
     285        if k in self._adapterCache:
    286286            return self._adapterCache[k]
    287287        else:
    288288            adapter = interface.__adapt__(self)
  • twisted/python/rebuild.py

    diff --git twisted/python/rebuild.py twisted/python/rebuild.py
    index 10a0b67..28a7675 100644
    def rebuild(module, doLog=1): 
    176176
    177177    values.update(classes)
    178178    values.update(functions)
    179     fromOldModule = values.has_key
     179    fromOldModule = values.__contains__
    180180    newclasses = newclasses.keys()
    181181    classes = classes.keys()
    182182    functions = functions.keys()
  • twisted/python/util.py

    diff --git twisted/python/util.py twisted/python/util.py
    index ee4cc8a..d9c506f 100644
    class InsensitiveDict: 
    5959    def has_key(self, key):
    6060        """Case insensitive test whether 'key' exists."""
    6161        k = self._lowerOrReturn(key)
    62         return self.data.has_key(k)
     62        return k in self.data
     63
    6364    __contains__=has_key
    6465
    6566    def _doPreserve(self, key):
    def uniquify(lst): 
    210211    dct = {}
    211212    result = []
    212213    for k in lst:
    213         if not dct.has_key(k): result.append(k)
     214        if k not in dct:
     215            result.append(k)
    214216        dct[k] = 1
    215217    return result
    216218
  • twisted/spread/pb.py

    diff --git twisted/spread/pb.py twisted/spread/pb.py
    index 76e803c..7e9a5b6 100644
    class Broker(banana.Banana): 
    844844        pbc = None
    845845        pbe = None
    846846        answerRequired = 1
    847         if kw.has_key('pbcallback'):
     847        if 'pbcallback' in kw:
    848848            pbc = kw['pbcallback']
    849849            del kw['pbcallback']
    850         if kw.has_key('pberrback'):
     850        if 'pberrback' in kw:
    851851            pbe = kw['pberrback']
    852852            del kw['pberrback']
    853         if kw.has_key('pbanswer'):
     853        if 'pbanswer' in kw:
    854854            assert (not pbe) and (not pbc), "You can't specify a no-answer requirement."
    855855            answerRequired = kw['pbanswer']
    856856            del kw['pbanswer']
  • twisted/test/test_log.py

    diff --git twisted/test/test_log.py twisted/test/test_log.py
    index 86f03d5..da661bf 100644
    class LogTest(unittest.TestCase): 
    3636        i = catcher.pop()
    3737        self.assertEqual(i["message"][0], "test")
    3838        self.assertEqual(i["testShouldCatch"], True)
    39         self.failUnless(i.has_key("time"))
     39        self.assertIn("time", i)
    4040        self.assertEqual(len(catcher), 0)
    4141
    4242
  • twisted/test/test_newcred.py

    diff --git twisted/test/test_newcred.py twisted/test/test_newcred.py
    index 870833a..01660cd 100644
    class TestRealm: 
    7171        self.avatars = {}
    7272
    7373    def requestAvatar(self, avatarId, mind, *interfaces):
    74         if self.avatars.has_key(avatarId):
     74        if avatarId in self.avatars:
    7575            avatar = self.avatars[avatarId]
    7676        else:
    7777            avatar = TestAvatar(avatarId)
  • twisted/web/client.py

    diff --git twisted/web/client.py twisted/web/client.py
    index 7e9a488..246eea6 100644
    class HTTPClientFactory(protocol.ClientFactory): 
    381381
    382382    def gotHeaders(self, headers):
    383383        self.response_headers = headers
    384         if headers.has_key('set-cookie'):
     384        if 'set-cookie' in headers:
    385385            for cookie in headers['set-cookie']:
    386386                cookparts = cookie.split(';')
    387387                cook = cookparts[0]
  • twisted/web/static.py

    diff --git twisted/web/static.py twisted/web/static.py
    index 3992ac8..6aa3d6a 100644
    def loadMimeTypes(mimetype_locations=['/etc/mime.types']): 
    138138def getTypeAndEncoding(filename, types, encodings, defaultType):
    139139    p, ext = os.path.splitext(filename)
    140140    ext = ext.lower()
    141     if encodings.has_key(ext):
     141    if ext in encodings:
    142142        enc = encodings[ext]
    143143        ext = os.path.splitext(p)[1].lower()
    144144    else:
  • twisted/web/sux.py

    diff --git twisted/web/sux.py twisted/web/sux.py
    index 13e6c76..d5ddc4f 100644
    class XMLParser(Protocol): 
    132132        # lenient behavior, because those may not have </script>
    133133        # -radix
    134134
    135         if (self.tagName == 'script'
    136             and not self.tagAttributes.has_key('src')):
     135        if (self.tagName == 'script' and 'src' not in self.tagAttributes):
    137136            # we do this ourselves rather than having begin_waitforendscript
    138137            # becuase that can get called multiple times and we don't want
    139138            # bodydata to get reset other than the first time.
  • twisted/web/twcgi.py

    diff --git twisted/web/twcgi.py twisted/web/twcgi.py
    index b1f001a..7f686e9 100644
    class CGIScript(resource.Resource): 
    118118            env[envname] = header
    119119        # Propogate our environment
    120120        for key, value in os.environ.items():
    121             if not env.has_key(key):
     121            if key not in env:
    122122                env[key] = value
    123123        # And they're off!
    124124        self.runProcess(env, request, qargs)
  • twisted/words/im/basechat.py

    diff --git twisted/words/im/basechat.py twisted/words/im/basechat.py
    index 39ead71..076275f 100644
    class ContactsList: 
    9393        @type newnick: C{str}
    9494        """
    9595        oldname = person.name
    96         if self.contacts.has_key(oldname):
     96        if oldname in self.contacts:
    9797            del self.contacts[oldname]
    9898            person.name = newnick
    9999            self.contacts[newnick] = person
    class ChatUI: 
    502502        @param newnick: The new C{name} C{person} will take.
    503503        """
    504504        oldnick = person.name
    505         if self.persons.has_key((oldnick, person.account)):
     505        if (oldnick, person.account) in self.persons:
    506506            conv = self.conversations.get(person)
    507507            if conv:
    508508                conv.contactChangedNick(person, newnick)
  • twisted/words/protocols/irc.py

    diff --git twisted/words/protocols/irc.py twisted/words/protocols/irc.py
    index 2bec909..65daa7a 100644
    class IRC(protocol.Protocol): 
    274274                  " look like a command to me: %s" % command
    275275
    276276        line = string.join([command] + list(parameter_list))
    277         if prefix.has_key('prefix'):
     277        if 'prefix' in prefix:
    278278            line = ":%s %s" % (prefix['prefix'], line)
    279279        self.sendLine(line)
    280280
    class IRCClient(basic.LineReceiver): 
    24162416        line = lowDequote(line)
    24172417        try:
    24182418            prefix, command, params = parsemsg(line)
    2419             if numeric_to_symbolic.has_key(command):
     2419            if command in numeric_to_symbolic:
    24202420                command = numeric_to_symbolic[command]
    24212421            self.handleCommand(command, prefix, params)
    24222422        except IRCBadMessage:
  • twisted/words/protocols/msn.py

    diff --git twisted/words/protocols/msn.py twisted/words/protocols/msn.py
    index 5e23a4d..79c0fa1 100644
    class PassportNexus(HTTPClient): 
    232232    def handleEndHeaders(self):
    233233        if self.connected:
    234234            self.transport.loseConnection()
    235         if not self.headers.has_key('passporturls') or not self.headers['passporturls'].has_key('dalogin'):
     235        if 'passporturls' not in self.headers or 'dalogin' not in self.headers['passporturls']:
    236236            self.deferred.errback(failure.Failure(failure.DefaultException("Invalid Nexus Reply")))
    237237        self.deferred.callback('https://' + self.headers['passporturls']['dalogin'])
    238238
    class PassportLogin(HTTPClient): 
    275275            self.transport.loseConnection()
    276276        authHeader = 'authentication-info'
    277277        _interHeader = 'www-authenticate'
    278         if self.headers.has_key(_interHeader):
     278        if _interHeader in self.headers:
    279279            authHeader = _interHeader
    280280        try:
    281281            info = self.headers[authHeader]
    class MSNMessage: 
    386386
    387387    def hasHeader(self, header):
    388388        """ check to see if the desired header exists """
    389         return self.headers.has_key(header)
     389        return header in self.headers
    390390
    391391    def getMessage(self):
    392392        """ return the message - not including headers """
    class MSNEventBase(LineReceiver): 
    602602        Fire the callback for the given id
    603603        if one exists and return 1, else return false
    604604        """
    605         if self.ids.has_key(id):
     605        if id in self.ids:
    606606            self.ids[id][0].callback(args)
    607607            del self.ids[id]
    608608            return 1
  • twisted/words/service.py

    diff --git twisted/words/service.py twisted/words/service.py
    index 388f7e6..0e4f8b6 100644
    class IRCUser(irc.IRC): 
    213213
    214214    # Make sendMessage a bit more useful to us
    215215    def sendMessage(self, command, *parameter_list, **kw):
    216         if not kw.has_key('prefix'):
     216        if 'prefix' not in kw:
    217217            kw['prefix'] = self.hostname
    218         if not kw.has_key('to'):
     218        if 'to' not in kw:
    219219            kw['to'] = self.name.encode(self.encoding)
    220220
    221221        arglist = [self, command, kw['to']] + list(parameter_list)
  • twisted/words/xish/domish.py

    diff --git twisted/words/xish/domish.py twisted/words/xish/domish.py
    index 407ee0c..3be7ed6 100644
    class _ListSerializer: 
    4343        return u"".join(self.writelist)
    4444
    4545    def getPrefix(self, uri):
    46         if not self.prefixes.has_key(uri):
     46        if uri not in self.prefixes:
    4747            self.prefixes[uri] = "xn%d" % (self.prefixCounter)
    4848            self.prefixCounter = self.prefixCounter + 1
    4949        return self.prefixes[uri]
    class Element(object): 
    451451
    452452    def hasAttribute(self, attrib):
    453453        """ Determine if the specified attribute exists """
    454         return self.attributes.has_key(self._dqa(attrib))
     454        return self._dqa(attrib) in self.attributes
    455455
    456456    def compareAttribute(self, attrib, value):
    457457        """ Safely compare the value of an attribute against a provided value.