gtfo has_key and range

This commit is contained in:
John Cote 2015-07-22 01:45:01 -04:00
parent c042107c4d
commit 4411cb805b
10 changed files with 22 additions and 23 deletions

View file

@ -50,7 +50,7 @@ class CatalogGardenItem(CatalogItem.CatalogItem):
def getPicture(self, avatar):
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]
animationName = GardenGlobals.Specials[self.gardenIndex]['photoAnimation'][1]
animationPath = photoModel + animationName
@ -79,8 +79,9 @@ class CatalogGardenItem(CatalogItem.CatalogItem):
def cleanupPicture(self):
CatalogItem.CatalogItem.cleanupPicture(self)
self.model.detachNode()
self.model = None
if hasattr(self, 'model') and self.model:
self.model.detachNode()
self.model = None
return
def output(self, store = -1):
@ -160,7 +161,7 @@ class CatalogGardenItem(CatalogItem.CatalogItem):
result = False
if canPlant < numBeansRequired:
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']
if avatar.shovelSkill < minSkill:
result = True

View file

@ -51,7 +51,7 @@ class CatalogToonStatueItem(CatalogGardenItem.CatalogGardenItem):
def getAllToonStatues(self):
self.statueList = []
for index in range(self.startPoseIndex, self.endPoseIndex + 1):
for index in xrange(self.startPoseIndex, self.endPoseIndex + 1):
self.statueList.append(CatalogToonStatueItem(index, 1, endPoseIndex=index))
return self.statueList

View file

@ -505,7 +505,7 @@ class DistributedEstateAI(DistributedObjectAI):
self.pond.setArea(ToontownGlobals.MyEstate)
self.pond.generateWithRequired(self.zoneId)
for i in range(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
for i in xrange(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
target = DistributedFishingTargetAI(self.air)
target.setPondDoId(self.pond.getDoId())
target.generateWithRequired(self.zoneId)
@ -540,8 +540,8 @@ class DistributedEstateAI(DistributedObjectAI):
self.spots.append(spot)
ButterflyGlobals.generateIndexes(self.zoneId, ButterflyGlobals.ESTATE)
for i in range(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.ESTATE]):
for j in range(0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.ESTATE]):
for i in xrange(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.ESTATE]):
for j in xrange(0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.ESTATE]):
bfly = DistributedButterflyAI.DistributedButterflyAI(self.air, ButterflyGlobals.ESTATE, i, self.zoneId)
bfly.generateWithRequired(self.zoneId)
bfly.start()
@ -844,7 +844,7 @@ class DistributedEstateAI(DistributedObjectAI):
return self.items[5]
def setIdList(self, idList):
for i in range(len(idList)):
for i in xrange(len(idList)):
if i >= 6:
return
self.toons[i] = idList[i]

View file

@ -1,12 +1,11 @@
from toontown.estate import DistributedPlantBase
from direct.directnotify import DirectNotifyGlobal
from toontown.estate import DistributedPlantBase
from toontown.estate.DistributedGardenBox import DistributedGardenBox
from toontown.estate import FlowerBase
from toontown.estate import GardenGlobals
from toontown.toontowngui import TTDialog
from toontown.toonbase import TTLocalizer
from DistributedGardenBox import DistributedGardenBox
DIRT_AS_WATER_INDICATOR = True
DIRT_MOUND_HEIGHT = 0.3
@ -30,7 +29,7 @@ class DistributedFlower(DistributedPlantBase.DistributedPlantBase, FlowerBase.Fl
def delete(self):
DistributedPlantBase.DistributedPlantBase.delete(self)
del self.dirtMound
del self.sandMound
@ -53,7 +52,7 @@ class DistributedFlower(DistributedPlantBase.DistributedPlantBase, FlowerBase.Fl
desat = wilt.find('**/*desat*')
bloom.hide()
leaves = wilt.findAllMatches('**/*leaf*')
for leafIndex in range(leaves.getNumPaths()):
for leafIndex in xrange(leaves.getNumPaths()):
leaf = leaves.getPath(leafIndex)
leaf.setColorScale(1.0, 0.3, 0.1, 1.0)

View file

@ -79,7 +79,7 @@ class DistributedGagTree(DistributedPlantBase.DistributedPlantBase):
self.model.reparentTo(self.rotateNode)
if self.isFruiting() and not self.isWilted():
self.fruits = []
for i in range(1, self.maxFruit + 1):
for i in xrange(1, self.maxFruit + 1):
pos = self.model.find('**/locator' + str(i))
if pos and not pos.isEmpty():
fruit = self.prop.copyTo(self.model)
@ -337,7 +337,7 @@ class DistributedGagTree(DistributedPlantBase.DistributedPlantBase):
picker.traverse(render)
if queue.getNumEntries() > 0:
queue.sortEntries()
for index in range(queue.getNumEntries()):
for index in xrange(queue.getNumEntries()):
entry = queue.getEntry(index)
if DistributedLawnDecor.recurseParent(entry.getIntoNode(), 'terrain_DNARoot'):
self.signModel.wrtReparentTo(render)

View file

@ -31,7 +31,7 @@ class DistributedGarden(DistributedObject.DistributedObject):
self.radius = 0
self.gridCells = 20
self.propTable = [None] * self.gridCells
for i in range(len(self.propTable)):
for i in xrange(len(self.propTable)):
self.propTable[i] = [None] * self.gridCells
self.dx = 1.0 / self.gridCells

View file

@ -137,7 +137,6 @@ class DistributedGardenPlot(DistributedLawnDecor.DistributedLawnDecor):
recipeKey = GardenGlobals.getRecipeKey(recipeStr, special)
if recipeKey >= 0:
species, variety = GardenGlobals.getSpeciesVarietyGivenRecipe(recipeKey)
print 'RK>0', species, variety
if species >= 0 and variety >= 0:
self.sendUpdate('plantFlower', [species, variety])
successPlanting = True

View file

@ -177,7 +177,7 @@ class DistributedLawnDecor(DistributedNode.DistributedNode, NodePath, ShadowCast
picker.traverse(render)
if queue.getNumEntries() > 0:
queue.sortEntries()
for index in range(queue.getNumEntries()):
for index in xrange(queue.getNumEntries()):
entry = queue.getEntry(index)
if recurseParent(entry.getIntoNode(), 'terrain_DNARoot'):
self.movieNode.setZ(entry.getSurfacePoint(self)[2])
@ -186,7 +186,7 @@ class DistributedLawnDecor(DistributedNode.DistributedNode, NodePath, ShadowCast
picker.traverse(render)
if queue.getNumEntries() > 0:
queue.sortEntries()
for index in range(queue.getNumEntries()):
for index in xrange(queue.getNumEntries()):
entry = queue.getEntry(index)
if recurseParent(entry.getIntoNode(), 'terrain_DNARoot'):
self.setZ(entry.getSurfacePoint(render)[2] + self.stickUp + 0.1)

View file

@ -43,10 +43,10 @@ class DistributedStatuary(DistributedLawnDecor.DistributedLawnDecor):
self.plantType = GardenGlobals.PlantAttributes[typeIndex]['plantType']
self.modelPath = GardenGlobals.PlantAttributes[typeIndex]['model']
self.pinballScore = None
if GardenGlobals.PlantAttributes[typeIndex].has_key('pinballScore'):
if 'pinballScore' in GardenGlobals.PlantAttributes[typeIndex]:
self.pinballScore = GardenGlobals.PlantAttributes[typeIndex]['pinballScore']
self.worldScale = 1.0
if GardenGlobals.PlantAttributes[typeIndex].has_key('worldScale'):
if 'worldScale' in GardenGlobals.PlantAttributes[typeIndex]:
self.worldScale = GardenGlobals.PlantAttributes[typeIndex]['worldScale']
return

View file

@ -112,7 +112,7 @@ class DistributedToonStatuary(DistributedStatuary.DistributedStatuary):
if sleeves:
sleeves.setTexture(desatSleeveTex, 1)
bottoms = torso.findAllMatches('**/torso-bot*')
for bottomNum in range(0, bottoms.getNumPaths()):
for bottomNum in xrange(0, bottoms.getNumPaths()):
bottom = bottoms.getPath(bottomNum)
if bottom:
if self.toon.style.torso[1] == 's':