Deprecate has_key and fix bugs

This commit is contained in:
John Cote 2015-07-05 21:53:42 -04:00
parent 7508de0d79
commit 568a076266
20 changed files with 30 additions and 30 deletions

View file

@ -334,7 +334,7 @@ class DistributedBuildingAI(DistributedObjectAI.DistributedObjectAI):
victorList.extend([None, None, None, None]) victorList.extend([None, None, None, None])
for i in xrange(0, 4): for i in xrange(0, 4):
victor = victorList[i] victor = victorList[i]
if victor == None or not self.air.doId2do.has_key(victor): if victor == None or not victor in self.air.doId2do:
victorList[i] = 0 victorList[i] = 0
continue continue
event = self.air.getAvatarExitEvent(victor) event = self.air.getAvatarExitEvent(victor)

View file

@ -15,7 +15,7 @@ class AccountDateAI(DistributedObjectAI):
return return
def callback(dclass, fields): def callback(dclass, fields):
if dclass is not None and dclass == self.air.dclassesByName['AccountAI'] and fields.has_key('CREATED'): if dclass is not None and dclass == self.air.dclassesByName['AccountAI'] and 'CREATED' in fields:
self.sendUpdateToAvatarId(avId, 'requestDateResult', [fields.get('CREATED')]) self.sendUpdateToAvatarId(avId, 'requestDateResult', [fields.get('CREATED')])
else: else:
self.sendUpdateToAvatarId(avId, 'requestDateResult', [None]) self.sendUpdateToAvatarId(avId, 'requestDateResult', [None])

View file

@ -63,7 +63,7 @@ ClosetToClothes = {
} }
ClothesToCloset = {} ClothesToCloset = {}
for closetId, maxClothes in ClosetToClothes.items(): for closetId, maxClothes in ClosetToClothes.items():
if not ClothesToCloset.has_key(maxClothes): if not maxClothes in ClothesToCloset:
ClothesToCloset[maxClothes] = (closetId,) ClothesToCloset[maxClothes] = (closetId,)
else: else:
ClothesToCloset[maxClothes] += (closetId,) ClothesToCloset[maxClothes] += (closetId,)

View file

@ -50,7 +50,7 @@ class CatalogGardenItem(CatalogItem.CatalogItem):
def getPicture(self, avatar): def getPicture(self, avatar):
photoModel = GardenGlobals.Specials[self.gardenIndex]['photoModel'] photoModel = GardenGlobals.Specials[self.gardenIndex]['photoModel']
if GardenGlobals.Specials[self.gardenIndex].has_key('photoAnimation'): if 'photoAnimation' in GardenGlobals.Specials[self.gardenIndex]:
modelPath = photoModel + GardenGlobals.Specials[self.gardenIndex]['photoAnimation'][0] modelPath = photoModel + GardenGlobals.Specials[self.gardenIndex]['photoAnimation'][0]
animationName = GardenGlobals.Specials[self.gardenIndex]['photoAnimation'][1] animationName = GardenGlobals.Specials[self.gardenIndex]['photoAnimation'][1]
animationPath = photoModel + animationName animationPath = photoModel + animationName
@ -161,7 +161,7 @@ class CatalogGardenItem(CatalogItem.CatalogItem):
result = False result = False
if canPlant < numBeansRequired: if canPlant < numBeansRequired:
result = True result = True
if not result and GardenGlobals.Specials.has_key(self.gardenIndex) and GardenGlobals.Specials[self.gardenIndex].has_key('minSkill'): if not result and self.gardenIndex in GardenGlobals.Specials and 'minSkill' in GardenGlobals.Specials[self.gardenIndex]:
minSkill = GardenGlobals.Specials[self.gardenIndex]['minSkill'] minSkill = GardenGlobals.Specials[self.gardenIndex]['minSkill']
if avatar.shovelSkill < minSkill: if avatar.shovelSkill < minSkill:
result = True result = True

View file

@ -1738,7 +1738,7 @@ class CatalogGenerator:
return return
def __recordScheduleItem(self, sched, weekCode, maybeWeekCode, item): def __recordScheduleItem(self, sched, weekCode, maybeWeekCode, item):
if not sched.has_key(item): if not item in sched:
sched[item] = [[], []] sched[item] = [[], []]
if weekCode != None: if weekCode != None:
sched[item][0].append(weekCode) sched[item][0].append(weekCode)

View file

@ -67,7 +67,7 @@ class CogdoCraneGame(DirectObject):
self.players.remove(cPlayer) self.players.remove(cPlayer)
break break
if self.toonId2Player.has_key(player.toon.doId): if player.toon.doId in self.toonId2Player:
del self.toonId2Player[player.toon.doId] del self.toonId2Player[player.toon.doId]
def handleToonLeft(self, toonId): def handleToonLeft(self, toonId):

View file

@ -161,11 +161,11 @@ class CogdoFlyingCameraManager:
name = entry.getIntoNode().getName() name = entry.getIntoNode().getName()
if name.find('col_') >= 0: if name.find('col_') >= 0:
np = entry.getIntoNodePath().getParent() np = entry.getIntoNodePath().getParent()
if not nodesInBetween.has_key(np): if not np in nodesInBetween:
nodesInBetween[np] = np.getParent() nodesInBetween[np] = np.getParent()
for np in nodesInBetween.keys(): for np in nodesInBetween.keys():
if self._betweenCamAndToon.has_key(np): if np in self._betweenCamAndToon:
del self._betweenCamAndToon[np] del self._betweenCamAndToon[np]
else: else:
np.setTransparency(True) np.setTransparency(True)

View file

@ -168,7 +168,7 @@ class CogdoFlyingLevel(DirectObject):
self.endPlatform.onstage() self.endPlatform.onstage()
self._currentQuadNum = quadNum self._currentQuadNum = quadNum
for i in xrange(0, max(self._currentQuadNum - self.quadVisibiltyBehind, 0)) + range(min(self._currentQuadNum + self.quadVisibiltyAhead + 1, self._numQuads), self._numQuads): for i in range(0, max(self._currentQuadNum - self.quadVisibiltyBehind, 0)) + range(min(self._currentQuadNum + self.quadVisibiltyAhead + 1, self._numQuads), self._numQuads):
self.quadrants[i].offstage() self.quadrants[i].offstage()
if i == 0: if i == 0:
self.startPlatform.offstage() self.startPlatform.offstage()

View file

@ -271,7 +271,7 @@ class CogdoMazeGame(DirectObject):
self.players.remove(cPlayer) self.players.remove(cPlayer)
break break
if self.toonId2Player.has_key(player.toon.doId): if player.toon.doId in self.toonId2Player:
del self.toonId2Player[player.toon.doId] del self.toonId2Player[player.toon.doId]
self.guiMgr.mazeMapGui.removeToon(player.toon) self.guiMgr.mazeMapGui.removeToon(player.toon)

View file

@ -19,7 +19,7 @@ class CogdoMazeSuit(MazeSuit, FSM, CogdoMazeSplattable):
MazeSuit.__init__(self, serialNum, maze, randomNumGen, data['cellWalkPeriod'], difficulty, data['dnaName'], startTile=startTile, walkSameDirectionProb=Globals.SuitWalkSameDirectionProb, walkTurnAroundProb=Globals.SuitWalkTurnAroundProb, uniqueRandomNumGen=False, walkAnimName=walkAnimName) MazeSuit.__init__(self, serialNum, maze, randomNumGen, data['cellWalkPeriod'], difficulty, data['dnaName'], startTile=startTile, walkSameDirectionProb=Globals.SuitWalkSameDirectionProb, walkTurnAroundProb=Globals.SuitWalkTurnAroundProb, uniqueRandomNumGen=False, walkAnimName=walkAnimName)
FSM.__init__(self, 'CogdoMazeSuit') FSM.__init__(self, 'CogdoMazeSuit')
CogdoMazeSplattable.__init__(self, self.suit, '%s-%i' % (Globals.SuitCollisionName, self.serialNum), 1.5) CogdoMazeSplattable.__init__(self, self.suit, '%s-%i' % (Globals.SuitCollisionName, self.serialNum), 1.5)
if data.has_key('scale'): if 'scale' in data:
self.suit.setScale(data['scale']) self.suit.setScale(data['scale'])
self.hp = data['hp'] self.hp = data['hp']
self.type = cogdoSuitType self.type = cogdoSuitType

View file

@ -72,7 +72,7 @@ class DistCogdoGame(DistCogdoGameBase, DistributedObject):
return return
def getToon(self, toonId): def getToon(self, toonId):
if self.cr.doId2do.has_key(toonId): if toonId in self.cr.doId2do:
return self.cr.doId2do[toonId] return self.cr.doId2do[toonId]
else: else:
return None return None

View file

@ -266,7 +266,7 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
self.ignore(toon.uniqueName('disable')) self.ignore(toon.uniqueName('disable'))
def __finishInterval(self, name): def __finishInterval(self, name):
if self.activeIntervals.has_key(name): if name in self.activeIntervals:
interval = self.activeIntervals[name] interval = self.activeIntervals[name]
if interval.isPlaying(): if interval.isPlaying():
interval.finish() interval.finish()
@ -315,7 +315,7 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
self.toons = [] self.toons = []
for toonId in toonIds: for toonId in toonIds:
if toonId != 0: if toonId != 0:
if self.cr.doId2do.has_key(toonId): if toonId in self.cr.doId2do:
toon = self.cr.doId2do[toonId] toon = self.cr.doId2do[toonId]
toon.stopSmooth() toon.stopSmooth()
self.toons.append(toon) self.toons.append(toon)
@ -333,7 +333,7 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
self.suits = [] self.suits = []
self.joiningReserves = [] self.joiningReserves = []
for suitId in suitIds: for suitId in suitIds:
if self.cr.doId2do.has_key(suitId): if suitId in self.cr.doId2do:
suit = self.cr.doId2do[suitId] suit = self.cr.doId2do[suitId]
self.suits.append(suit) self.suits.append(suit)
suit.fsm.request('Battle') suit.fsm.request('Battle')
@ -353,7 +353,7 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
self.reserveSuits = [] self.reserveSuits = []
for index in xrange(len(reserveIds)): for index in xrange(len(reserveIds)):
suitId = reserveIds[index] suitId = reserveIds[index]
if self.cr.doId2do.has_key(suitId): if suitId in self.cr.doId2do:
suit = self.cr.doId2do[suitId] suit = self.cr.doId2do[suitId]
self.reserveSuits.append((suit, values[index])) self.reserveSuits.append((suit, values[index]))
else: else:

View file

@ -198,7 +198,7 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
if not avId in self.toons: if not avId in self.toons:
self.toons.append(avId) self.toons.append(avId)
if self.air.doId2do.has_key(avId): if avId in self.air.doId2do:
event = self.air.getAvatarExitEvent(avId) event = self.air.getAvatarExitEvent(avId)
self.accept(event, self.__handleUnexpectedExit, [avId]) self.accept(event, self.__handleUnexpectedExit, [avId])

View file

@ -403,19 +403,19 @@ class DistributedBanquetTable(DistributedObject.DistributedObject, FSM.FSM, Banq
self.activeIntervals = {} self.activeIntervals = {}
def clearInterval(self, name, finish = 1): def clearInterval(self, name, finish = 1):
if self.activeIntervals.has_key(name): if name in self.activeIntervals:
ival = self.activeIntervals[name] ival = self.activeIntervals[name]
if finish: if finish:
ival.finish() ival.finish()
else: else:
ival.pause() ival.pause()
if self.activeIntervals.has_key(name): if name in self.activeIntervals:
del self.activeIntervals[name] del self.activeIntervals[name]
else: else:
self.notify.debug('interval: %s already cleared' % name) self.notify.debug('interval: %s already cleared' % name)
def finishInterval(self, name): def finishInterval(self, name):
if self.activeIntervals.has_key(name): if name in self.activeIntervals:
interval = self.activeIntervals[name] interval = self.activeIntervals[name]
interval.finish() interval.finish()

View file

@ -266,7 +266,7 @@ class DistributedCannon(DistributedObject.DistributedObject):
self.curPinballScore = 0 self.curPinballScore = 0
self.curPinballMultiplier = 1 self.curPinballMultiplier = 1
self.incrementPinballInfo(0, 0) self.incrementPinballInfo(0, 0)
if self.cr.doId2do.has_key(self.avId): if self.avId in self.cr.doId2do:
self.av = self.cr.doId2do[self.avId] self.av = self.cr.doId2do[self.avId]
self.acceptOnce(self.av.uniqueName('disable'), self.__avatarGone) self.acceptOnce(self.av.uniqueName('disable'), self.__avatarGone)
self.av.stopSmooth() self.av.stopSmooth()

View file

@ -241,7 +241,7 @@ def getBodyRarity(bodyIndex):
for zoneId in PetRarities['body']: for zoneId in PetRarities['body']:
for body in PetRarities['body'][zoneId]: for body in PetRarities['body'][zoneId]:
totalWeight += PetRarities['body'][zoneId][body] totalWeight += PetRarities['body'][zoneId][body]
if weight.has_key(body): if body in weight:
weight[body] += PetRarities['body'][zoneId][body] weight[body] += PetRarities['body'][zoneId][body]
else: else:
weight[body] = PetRarities['body'][zoneId][body] weight[body] = PetRarities['body'][zoneId][body]

View file

@ -258,7 +258,7 @@ class PhotoAlbumPage(ShtikerPage.ShtikerPage):
del self.photos[photo] del self.photos[photo]
for photo in newPhotos: for photo in newPhotos:
if not self.photos.has_key(photo): if not photo in self.photos:
photoButton = self.makePhotoButton(photo) photoButton = self.makePhotoButton(photo)
self.scrollList.addItem(photoButton) self.scrollList.addItem(photoButton)
self.photos[photo] = photoButton self.photos[photo] = photoButton

View file

@ -563,7 +563,7 @@ class SuitPlannerBase:
self.notify.warning('interactive prop %s at %s not associated with a a battle' % (childDnaGroup, zoneId)) self.notify.warning('interactive prop %s at %s not associated with a a battle' % (childDnaGroup, zoneId))
elif battleCellId == 0: elif battleCellId == 0:
if self.cellToGagBonusDict.has_key(zoneId): if zoneId in self.cellToGagBonusDict:
self.notify.error('FIXME battle cell at zone %s has two props %s %s linked to it' % (zoneId, self.cellToGagBonusDict[zoneId], childDnaGroup)) self.notify.error('FIXME battle cell at zone %s has two props %s %s linked to it' % (zoneId, self.cellToGagBonusDict[zoneId], childDnaGroup))
else: else:
name = childDnaGroup.getName() name = childDnaGroup.getName()

View file

@ -21,7 +21,7 @@ class DistributedNPCPetclerkAI(DistributedNPCToonBaseAI):
def avatarEnter(self): def avatarEnter(self):
avId = self.air.getAvatarIdFromSender() avId = self.air.getAvatarIdFromSender()
if not self.air.doId2do.has_key(avId): if not avId in self.air.doId2do:
self.notify.warning('Avatar: %s not found' % avId) self.notify.warning('Avatar: %s not found' % avId)
return return
if self.isBusy(): if self.isBusy():

View file

@ -635,11 +635,11 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
tossTrack = self.tossTrack tossTrack = self.tossTrack
self.tossTrack = None self.tossTrack = None
tossTrack.finish() tossTrack.finish()
if self.pieTracks.has_key(sequence): if sequence in self.pieTracks:
pieTrack = self.pieTracks[sequence] pieTrack = self.pieTracks[sequence]
del self.pieTracks[sequence] del self.pieTracks[sequence]
pieTrack.finish() pieTrack.finish()
if self.splatTracks.has_key(sequence): if sequence in self.splatTracks:
splatTrack = self.splatTracks[sequence] splatTrack = self.splatTracks[sequence]
del self.splatTracks[sequence] del self.splatTracks[sequence]
splatTrack.finish() splatTrack.finish()
@ -679,7 +679,7 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.__piePowerMeter.hide() self.__piePowerMeter.hide()
def __finishPieTrack(self, sequence): def __finishPieTrack(self, sequence):
if self.pieTracks.has_key(sequence): if sequence in self.pieTracks:
pieTrack = self.pieTracks[sequence] pieTrack = self.pieTracks[sequence]
del self.pieTracks[sequence] del self.pieTracks[sequence]
pieTrack.finish() pieTrack.finish()
@ -691,7 +691,7 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
return return
sequence = int(entry.getFromNodePath().getNetTag('pieSequence')) sequence = int(entry.getFromNodePath().getNetTag('pieSequence'))
self.__finishPieTrack(sequence) self.__finishPieTrack(sequence)
if self.splatTracks.has_key(sequence): if sequence in self.splatTracks:
splatTrack = self.splatTracks[sequence] splatTrack = self.splatTracks[sequence]
del self.splatTracks[sequence] del self.splatTracks[sequence]
splatTrack.finish() splatTrack.finish()