Fix use of has_key and map()

This commit is contained in:
rdb 2013-12-17 19:49:09 +00:00
parent c1273d5684
commit 88048bf3da
57 changed files with 205 additions and 214 deletions

View File

@ -1006,7 +1006,7 @@ class Actor(DirectObject, NodePath):
return
# remove the part
if (partBundleDict.has_key(partName)):
if (partName in partBundleDict):
partBundleDict[partName].partBundleNP.removeNode()
del(partBundleDict[partName])
@ -1019,7 +1019,7 @@ class Actor(DirectObject, NodePath):
return
# remove the animations
if (partDict.has_key(partName)):
if (partName in partDict):
del(partDict[partName])
# remove the bundle handle, in case this part is ever
@ -1802,7 +1802,7 @@ class Actor(DirectObject, NodePath):
# Get all main parts, but not sub-parts.
animDictItems = []
for thisPart, animDict in partDict.items():
if not self.__subpartDict.has_key(thisPart):
if thisPart not in self.__subpartDict:
animDictItems.append((thisPart, animDict))
else:

View File

@ -137,7 +137,7 @@ class ClusterClient(DirectObject.DirectObject):
object = pair[1]
name = self.controlMappings[object][0]
serverList = self.controlMappings[object][1]
if (self.objectMappings.has_key(object)):
if (object in self.objectMappings):
self.moveObject(self.objectMappings[object],name,serverList,
self.controlOffsets[object], self.objectHasColor[object])
self.sendNamedMovementDone()
@ -204,20 +204,20 @@ class ClusterClient(DirectObject.DirectObject):
def addNamedObjectMapping(self,object,name,hasColor = True):
if (not self.objectMappings.has_key(name)):
if (name not in self.objectMappings):
self.objectMappings[name] = object
self.objectHasColor[name] = hasColor
else:
self.notify.debug('attempt to add duplicate named object: '+name)
def removeObjectMapping(self,name):
if (self.objectMappings.has_key(name)):
if (name in self.objectMappings):
self.objectMappings.pop(name)
def addControlMapping(self,objectName,controlledName, serverList = None,
offset = None, priority = 0):
if (not self.controlMappings.has_key(objectName)):
if (objectName not in self.controlMappings):
if (serverList == None):
serverList = range(len(self.serverList))
if (offset == None):
@ -239,11 +239,11 @@ class ClusterClient(DirectObject.DirectObject):
#self.notify.debug('attempt to add duplicate controlled object: '+name)
def setControlMappingOffset(self,objectName,offset):
if (self.controlMappings.has_key(objectName)):
if (objectName in self.controlMappings):
self.controlOffsets[objectName] = offset
def removeControlMapping(self,name, serverList = None):
if (self.controlMappings.has_key(name)):
if (name in self.controlMappings):
if (serverList == None):
self.controlMappings.pop(name)
@ -299,7 +299,7 @@ class ClusterClient(DirectObject.DirectObject):
def selectNodePath(self, nodePath):
name = self.getNodePathName(nodePath)
if self.taggedObjects.has_key(name):
if name in self.taggedObjects:
taskMgr.remove("moveSelectedTask")
tag = self.taggedObjects[name]
function = tag["selectFunction"]
@ -312,7 +312,7 @@ class ClusterClient(DirectObject.DirectObject):
def deselectNodePath(self, nodePath):
name = self.getNodePathName(nodePath)
if self.taggedObjects.has_key(name):
if name in self.taggedObjects:
tag = self.taggedObjects[name]
function = tag["deselectFunction"]
args = tag["deselectArgs"]
@ -323,7 +323,7 @@ class ClusterClient(DirectObject.DirectObject):
def sendCamFrustum(self, focalLength, filmSize, filmOffset, indexList=[]):
if indexList:
serverList = map(lambda i: self.serverList[i], indexList)
serverList = [self.serverList[i] for i in indexList]
else:
serverList = self.serverList
for server in serverList:
@ -381,7 +381,7 @@ class ClusterClient(DirectObject.DirectObject):
#print "name"
#if (name == "camNode"):
# print x,y,z,h,p,r, sx, sy, sz,red,g,b,a, hidden
if (self.objectMappings.has_key(name)):
if (name in self.objectMappings):
self.objectMappings[name].setPosHpr(render, x, y, z, h, p, r)
self.objectMappings[name].setScale(render,sx,sy,sz)
if (self.objectHasColor[name]):
@ -598,7 +598,7 @@ def createClusterClient():
# setup camera offsets based on cluster-config
clusterConfig = base.config.GetString('cluster-config', 'single-server')
# No cluster config specified!
if not ClientConfigs.has_key(clusterConfig):
if clusterConfig not in ClientConfigs:
base.notify.warning(
'createClusterClient: %s cluster-config is undefined.' %
clusterConfig)

View File

@ -102,14 +102,14 @@ class ClusterServer(DirectObject.DirectObject):
def addNamedObjectMapping(self,object,name,hasColor = True,
priority = 0):
if (not self.objectMappings.has_key(name)):
if (name not in self.objectMappings):
self.objectMappings[name] = object
self.objectHasColor[name] = hasColor
else:
self.notify.debug('attempt to add duplicate named object: '+name)
def removeObjectMapping(self,name):
if (self.objectMappings.has_key(name)):
if (name in self.objectMappings):
self.objectMappings.pop(name)
@ -125,7 +125,7 @@ class ClusterServer(DirectObject.DirectObject):
def addControlMapping(self,objectName,controlledName, offset = None,
priority = 0):
if (not self.controlMappings.has_key(objectName)):
if (objectName not in self.controlMappings):
self.controlMappings[objectName] = controlledName
if (offset == None):
offset = Vec3(0,0,0)
@ -136,12 +136,12 @@ class ClusterServer(DirectObject.DirectObject):
self.notify.debug('attempt to add duplicate controlled object: '+name)
def setControlMappingOffset(self,objectName,offset):
if (self.controlMappings.has_key(objectName)):
if (objectName in self.controlMappings):
self.controlOffsets[objectName] = offset
def removeControlMapping(self,name):
if (self.controlMappings.has_key(name)):
if (name in self.controlMappings):
self.controlMappings.pop(name)
self.controlPriorities.pop(name)
self.redoSortedPriorities()
@ -156,7 +156,7 @@ class ClusterServer(DirectObject.DirectObject):
for pair in self.sortedControlPriorities:
object = pair[1]
name = self.controlMappings[object]
if (self.objectMappings.has_key(object)):
if (object in self.objectMappings):
self.moveObject(self.objectMappings[object],name,self.controlOffsets[object],
self.objectHasColor[object])
@ -297,7 +297,7 @@ class ClusterServer(DirectObject.DirectObject):
def handleNamedMovement(self, data):
""" Update cameraJig position to reflect latest position """
(name,x, y, z, h, p, r,sx,sy,sz, red, g, b, a, hidden) = data
if (self.objectMappings.has_key(name)):
if (name in self.objectMappings):
self.objectMappings[name].setPosHpr(render, x, y, z, h, p, r)
self.objectMappings[name].setScale(render,sx,sy,sz)
self.objectMappings[name].setColor(red,g,b,a)

View File

@ -165,7 +165,7 @@ if (sys.platform == "win32"):
def limitedCopyTree(src, dst, rmdir):
if (os.path.isdir(src)):
if (rmdir.has_key(os.path.basename(src))):
if (os.path.basename(src) in rmdir):
return
if (not os.path.isdir(dst)): os.mkdir(dst)
for x in os.listdir(src):

View File

@ -48,11 +48,11 @@ class DirectLights(NodePath):
self.delete(light)
def asList(self):
return map(lambda n, s=self: s[n], self.getNameList())
return [self[n] for n in self.getNameList()]
def getNameList(self):
# Return a sorted list of all lights in the light dict
nameList = map(lambda x: x.getName(), self.lightDict.values())
nameList = [x.getName() for x in self.lightDict.values()]
nameList.sort()
return nameList

View File

@ -42,7 +42,7 @@ class DirectSession(DirectObject):
self.fIgnoreDirectOnlyKeyMap = 0 # [gjeon] to skip old direct controls in new LE
self.drList = DisplayRegionList()
self.iRayList = map(lambda x: x.iRay, self.drList)
self.iRayList = [x.iRay for x in self.drList]
self.dr = self.drList[0]
self.win = base.win
self.camera = base.camera
@ -196,8 +196,8 @@ class DirectSession(DirectObject):
'alt', 'alt-up', 'alt-repeat',
]
keyList = map(chr, range(97, 123))
keyList.extend(map(chr, range(48, 58)))
keyList = [chr(i) for i in range(97, 123)]
keyList.extend([chr(i) for i in range(48, 58)])
keyList.extend(["`", "-", "=", "[", "]", ";", "'", ",", ".", "/", "\\"])
self.specialKeys = ['escape', 'delete', 'page_up', 'page_down', 'enter']
@ -209,8 +209,8 @@ class DirectSession(DirectObject):
return "shift-%s"%a
self.keyEvents = keyList[:]
self.keyEvents.extend(map(addCtrl, keyList))
self.keyEvents.extend(map(addShift, keyList))
self.keyEvents.extend(list(map(addCtrl, keyList)))
self.keyEvents.extend(list(map(addShift, keyList)))
self.keyEvents.extend(self.specialKeys)
self.mouseEvents = ['mouse1', 'mouse1-up',
@ -996,7 +996,7 @@ class DirectSession(DirectObject):
# Get last item off of redo list
undoGroup = self.popUndoGroup()
# Record redo information
nodePathList = map(lambda x: x[0], undoGroup)
nodePathList = [x[0] for x in undoGroup]
self.pushRedo(nodePathList)
# Now undo xform for group
for pose in undoGroup:
@ -1010,7 +1010,7 @@ class DirectSession(DirectObject):
# Get last item off of redo list
redoGroup = self.popRedoGroup()
# Record undo information
nodePathList = map(lambda x: x[0], redoGroup)
nodePathList = [x[0] for x in redoGroup]
self.pushUndo(nodePathList, fResetRedo = 0)
# Redo xform
for pose in redoGroup:

View File

@ -79,7 +79,7 @@ def getFileData(filename, separator = ','):
if l:
# If its a valid line, split on separator and
# strip leading/trailing whitespace from each element
data = map(lambda s: s.strip(), l.split(separator))
data = [s.strip() for s in l.split(separator)]
fileData.append(data)
return fileData

View File

@ -59,7 +59,7 @@ class CRCache:
doId = distObj.getDoId()
# Error check
success = False
if self.dict.has_key(doId):
if doId in self.dict:
CRCache.notify.warning("Double cache attempted for distObj "
+ str(doId))
else:
@ -89,7 +89,7 @@ class CRCache:
def retrieve(self, doId):
assert self.checkCache()
if self.dict.has_key(doId):
if doId in self.dict:
# Find the object
distObj = self.dict[doId]
# Remove it from the dictionary
@ -103,11 +103,11 @@ class CRCache:
return None
def contains(self, doId):
return self.dict.has_key(doId)
return doId in self.dict
def delete(self, doId):
assert self.checkCache()
assert self.dict.has_key(doId)
assert doId in self.dict
# Look it up
distObj = self.dict[doId]
# Remove it from the dict and fifo

View File

@ -372,7 +372,7 @@ class ClientRepository(ClientRepositoryBase):
This is not a distributed message and does not delete the
object on the server or on any other client.
"""
if self.doId2do.has_key(doId):
if doId in self.doId2do:
# If it is in the dictionary, remove it.
obj = self.doId2do[doId]
# Remove it from the dictionary

View File

@ -221,7 +221,7 @@ class ClientRepositoryBase(ConnectionRepository):
return Task.done
def generateWithRequiredFields(self, dclass, doId, di, parentId, zoneId):
if self.doId2do.has_key(doId):
if doId in self.doId2do:
# ...it is in our dictionary.
# Just update it.
distObj = self.doId2do[doId]
@ -269,7 +269,7 @@ class ClientRepositoryBase(ConnectionRepository):
def generateWithRequiredOtherFields(self, dclass, doId, di,
parentId = None, zoneId = None):
if self.doId2do.has_key(doId):
if doId in self.doId2do:
# ...it is in our dictionary.
# Just update it.
distObj = self.doId2do[doId]
@ -315,7 +315,7 @@ class ClientRepositoryBase(ConnectionRepository):
return distObj
def generateWithRequiredOtherFieldsOwner(self, dclass, doId, di):
if self.doId2ownerView.has_key(doId):
if doId in self.doId2ownerView:
# ...it is in our dictionary.
# Just update it.
self.notify.error('duplicate owner generate for %s (%s)' % (
@ -359,7 +359,7 @@ class ClientRepositoryBase(ConnectionRepository):
def disableDoId(self, doId, ownerView=False):
table, cache = self.getTables(ownerView)
# Make sure the object exists
if table.has_key(doId):
if doId in table:
# Look up the object
distObj = table[doId]
# remove the object from the dictionary
@ -378,7 +378,7 @@ class ClientRepositoryBase(ConnectionRepository):
# make sure we're not leaking
distObj.detectLeaks()
elif self.deferredDoIds.has_key(doId):
elif doId in self.deferredDoIds:
# The object had been deferred. Great; we don't even have
# to generate it now.
del self.deferredDoIds[doId]

View File

@ -65,7 +65,7 @@ class DistributedCartesianGridAI(DistributedNodeAI, CartesianGridBase):
# Remove grid parent for this av
avId = av.doId
if self.gridObjects.has_key(avId):
if avId in self.gridObjects:
del self.gridObjects[avId]
# Stop task if there are no more av's being managed

View File

@ -147,7 +147,7 @@ class DoInterestManager(DirectObject.DirectObject):
# still a valid interest handle
if not isinstance(handle, InterestHandle):
return False
return DoInterestManager._interests.has_key(handle.asInt())
return handle.asInt() in DoInterestManager._interests
def updateInterestDescription(self, handle, desc):
iState = DoInterestManager._interests.get(handle.asInt())
@ -240,7 +240,7 @@ class DoInterestManager(DirectObject.DirectObject):
if not event:
event = self._getAnonymousEvent('removeInterest')
handle = handle.asInt()
if DoInterestManager._interests.has_key(handle):
if handle in DoInterestManager._interests:
existed = True
intState = DoInterestManager._interests[handle]
if event:
@ -287,7 +287,7 @@ class DoInterestManager(DirectObject.DirectObject):
assert isinstance(handle, InterestHandle)
existed = False
handle = handle.asInt()
if DoInterestManager._interests.has_key(handle):
if handle in DoInterestManager._interests:
existed = True
intState = DoInterestManager._interests[handle]
if intState.isPendingDelete():
@ -345,7 +345,7 @@ class DoInterestManager(DirectObject.DirectObject):
exists = False
if event is None:
event = self._getAnonymousEvent('alterInterest')
if DoInterestManager._interests.has_key(handle):
if handle in DoInterestManager._interests:
if description is not None:
DoInterestManager._interests[handle].desc = description
else:
@ -427,7 +427,7 @@ class DoInterestManager(DirectObject.DirectObject):
"""
assert DoInterestManager.notify.debugCall()
if DoInterestManager._interests.has_key(handle):
if handle in DoInterestManager._interests:
if DoInterestManager._interests[handle].isPendingDelete():
# make sure there is no pending event for this interest
if DoInterestManager._interests[handle].context == NO_CONTEXT:
@ -594,7 +594,7 @@ class DoInterestManager(DirectObject.DirectObject):
DoInterestManager.notify.debug(
"handleInterestDoneMessage--> Received handle %s, context %s" % (
handle, contextId))
if DoInterestManager._interests.has_key(handle):
if handle in DoInterestManager._interests:
eventsToSend = []
# if the context matches, send out the event
if contextId == DoInterestManager._interests[handle].context:

View File

@ -168,7 +168,7 @@ class OldClientRepository(ClientRepositoryBase):
dclass.stopGenerate()
def generateWithRequiredFields(self, dclass, doId, di):
if self.doId2do.has_key(doId):
if doId in self.doId2do:
# ...it is in our dictionary.
# Just update it.
distObj = self.doId2do[doId]

View File

@ -57,7 +57,7 @@ class ParentMgr:
self.pendingParentToken2children[parentToken].remove(child)
def requestReparent(self, child, parentToken):
if self.token2nodepath.has_key(parentToken):
if parentToken in self.token2nodepath:
# this parent has registered
# this child may already be waiting on a different parent;
# make sure they aren't any more
@ -82,7 +82,7 @@ class ParentMgr:
child.reparentTo(hidden)
def registerParent(self, token, parent):
if self.token2nodepath.has_key(token):
if token in self.token2nodepath:
self.notify.error(
"registerParent: token '%s' already registered, referencing %s" %
(token, repr(self.token2nodepath[token])))
@ -141,7 +141,7 @@ class ParentMgr:
del self.pendingChild2parentToken[child]
def unregisterParent(self, token):
if not self.token2nodepath.has_key(token):
if token not in self.token2nodepath:
self.notify.warning("unregisterParent: unknown parent token '%s'" %
token)
return

View File

@ -699,7 +699,7 @@ class ServerRepository:
if self.notify.getDebug():
self.notify.debug(
"ServerRepository sending to all in zone %s except %s:" % (zoneId, map(lambda c: c.doIdBase, exceptionList)))
"ServerRepository sending to all in zone %s except %s:" % (zoneId, [c.doIdBase for c in exceptionList]))
#datagram.dumpHex(ostream)
for client in self.zonesToClients.get(zoneId, []):
@ -716,7 +716,7 @@ class ServerRepository:
if self.notify.getDebug():
self.notify.debug(
"ServerRepository sending to all except %s:" % (map(lambda c: c.doIdBase, exceptionList),))
"ServerRepository sending to all except %s:" % ([c.doIdBase for c in exceptionList],))
#datagram.dumpHex(ostream)
for client in self.clientsByConnection.values():

View File

@ -12,7 +12,7 @@ class FFIEnvironment:
self.manifests = []
def addType(self, typeDescriptor, name):
if self.types.has_key(name):
if name in self.types:
FFIConstants.notify.info('Redefining type named: ' + name)
self.types[name] = typeDescriptor

View File

@ -238,7 +238,7 @@ class FFIInterrogateDatabase:
self.environment = FFIEnvironment.FFIEnvironment()
def isDefinedType(self, typeIndex):
return self.typeIndexMap.has_key(typeIndex)
return typeIndex in self.typeIndexMap
def constructDescriptor(self, typeIndex):
if interrogate_type_is_atomic(typeIndex):

View File

@ -337,7 +337,7 @@ class FFIMethodArgumentTree:
# methodSpec in this dictionary
self.tree[typeDesc] = [None, methodSpec]
else:
if self.tree.has_key(typeDesc):
if typeDesc in self.tree:
# If there already is a tree here, jump into and pass the
# cdr of the arg list
subTree = self.tree[typeDesc][0]

View File

@ -108,7 +108,7 @@ def classNameFromCppName(cppName):
firstChar = 0
else:
className = className + char
if classRenameDictionary.has_key(className):
if className in classRenameDictionary:
className = classRenameDictionary[className]
if (className == ''):

View File

@ -86,28 +86,28 @@ class CommonFilters:
auxbits = 0
needtex = {}
needtex["color"] = True
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
needtex["aux"] = True
auxbits |= AuxBitplaneAttrib.ABOAuxNormal
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
needtex["depth"] = True
needtex["ssao0"] = True
needtex["ssao1"] = True
needtex["ssao2"] = True
needtex["aux"] = True
auxbits |= AuxBitplaneAttrib.ABOAuxNormal
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
needtex["blur0"] = True
needtex["blur1"] = True
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
needtex["bloom0"] = True
needtex["bloom1"] = True
needtex["bloom2"] = True
needtex["bloom3"] = True
auxbits |= AuxBitplaneAttrib.ABOGlow
if (configuration.has_key("ViewGlow")):
if ("ViewGlow" in configuration):
auxbits |= AuxBitplaneAttrib.ABOGlow
if (configuration.has_key("VolumetricLighting")):
if ("VolumetricLighting" in configuration):
needtex[configuration["VolumetricLighting"].source] = True
for tex in needtex:
self.textures[tex] = Texture("scene-"+tex)
@ -120,7 +120,7 @@ class CommonFilters:
self.cleanup()
return False
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
blur0=self.textures["blur0"]
blur1=self.textures["blur1"]
self.blur.append(self.manager.renderQuadInto(colortex=blur0,div=2))
@ -130,7 +130,7 @@ class CommonFilters:
self.blur[1].setShaderInput("src", blur0)
self.blur[1].setShader(self.loadShader("filter-blury.sha"))
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
ssao0=self.textures["ssao0"]
ssao1=self.textures["ssao1"]
ssao2=self.textures["ssao2"]
@ -146,7 +146,7 @@ class CommonFilters:
self.ssao[2].setShaderInput("src", ssao1)
self.ssao[2].setShader(self.loadShader("filter-blury.sha"))
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
bloomconf = configuration["Bloom"]
bloom0=self.textures["bloom0"]
bloom1=self.textures["bloom1"]
@ -180,74 +180,74 @@ class CommonFilters:
text += " uniform float4 texpad_txcolor,\n"
text += " uniform float4 texpix_txcolor,\n"
text += " out float4 l_texcoordC : TEXCOORD0,\n"
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
text += " uniform float4 texpad_txaux,\n"
text += " uniform float4 texpix_txaux,\n"
text += " out float4 l_texcoordN : TEXCOORD1,\n"
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
text += " uniform float4 texpad_txbloom3,\n"
text += " out float4 l_texcoordB : TEXCOORD2,\n"
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
text += " uniform float4 texpad_txblur1,\n"
text += " out float4 l_texcoordBS : TEXCOORD3,\n"
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
text += " uniform float4 texpad_txssao2,\n"
text += " out float4 l_texcoordAO : TEXCOORD4,\n"
text += " uniform float4x4 mat_modelproj)\n"
text += "{\n"
text += " l_position=mul(mat_modelproj, vtx_position);\n"
text += " l_texcoordC=(vtx_position.xzxz * texpad_txcolor) + texpad_txcolor;\n"
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
text += " l_texcoordN=(vtx_position.xzxz * texpad_txaux) + texpad_txaux;\n"
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
text += " l_texcoordB=(vtx_position.xzxz * texpad_txbloom3) + texpad_txbloom3;\n"
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
text += " l_texcoordBS=(vtx_position.xzxz * texpad_txblur1) + texpad_txblur1;\n"
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
text += " l_texcoordAO=(vtx_position.xzxz * texpad_txssao2) + texpad_txssao2;\n"
if (configuration.has_key("HalfPixelShift")):
if ("HalfPixelShift" in configuration):
text += " l_texcoordC+=texpix_txcolor*0.5;\n"
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
text += " l_texcoordN+=texpix_txaux*0.5;\n"
text += "}\n"
text += "void fshader(\n"
text += "float4 l_texcoordC : TEXCOORD0,\n"
text += "uniform float4 texpix_txcolor,\n"
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
text += "float4 l_texcoordN : TEXCOORD1,\n"
text += "uniform float4 texpix_txaux,\n"
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
text += "float4 l_texcoordB : TEXCOORD2,\n"
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
text += "float4 l_texcoordBS : TEXCOORD3,\n"
text += "uniform float4 k_blurval,\n"
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
text += "float4 l_texcoordAO : TEXCOORD4,\n"
for key in self.textures:
text += "uniform sampler2D k_tx" + key + ",\n"
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
text += "uniform float4 k_cartoonseparation,\n"
text += "uniform float4 k_cartooncolor,\n"
if (configuration.has_key("VolumetricLighting")):
if ("VolumetricLighting" in configuration):
text += "uniform float4 k_casterpos,\n"
text += "uniform float4 k_vlparams,\n"
text += "out float4 o_color : COLOR)\n"
text += "{\n"
text += " o_color = tex2D(k_txcolor, l_texcoordC.xy);\n"
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
text += CARTOON_BODY
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
text += "o_color *= tex2D(k_txssao2, l_texcoordAO.xy).r;\n"
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
text += " o_color = lerp(tex2D(k_txblur1, l_texcoordBS.xy), o_color, k_blurval.x);\n"
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
text += "o_color = saturate(o_color);\n";
text += "float4 bloom = 0.5*tex2D(k_txbloom3, l_texcoordB.xy);\n"
text += "o_color = 1-((1-bloom)*(1-o_color));\n"
if (configuration.has_key("ViewGlow")):
if ("ViewGlow" in configuration):
text += "o_color.r = o_color.a;\n"
if (configuration.has_key("VolumetricLighting")):
if ("VolumetricLighting" in configuration):
text += "float decay = 1.0f;\n"
text += "float2 curcoord = l_texcoordC.xy;\n"
text += "float2 lightdir = curcoord - k_casterpos.xy;\n"
@ -262,7 +262,7 @@ class CommonFilters:
text += " decay *= k_vlparams.y;\n"
text += "}\n"
text += "o_color += float4(vlcolor * k_vlparams.z, 1);\n"
if (configuration.has_key("Inverted")):
if ("Inverted" in configuration):
text += "o_color = float4(1, 1, 1, 1) - o_color;\n"
text += "}\n"
@ -273,18 +273,18 @@ class CommonFilters:
self.task = taskMgr.add(self.update, "common-filters-update")
if (changed == "CartoonInk") or fullrebuild:
if (configuration.has_key("CartoonInk")):
if ("CartoonInk" in configuration):
c = configuration["CartoonInk"]
self.finalQuad.setShaderInput("cartoonseparation", Vec4(c.separation, 0, c.separation, 0))
self.finalQuad.setShaderInput("cartooncolor", c.color)
if (changed == "BlurSharpen") or fullrebuild:
if (configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in configuration):
blurval = configuration["BlurSharpen"]
self.finalQuad.setShaderInput("blurval", Vec4(blurval, blurval, blurval, blurval))
if (changed == "Bloom") or fullrebuild:
if (configuration.has_key("Bloom")):
if ("Bloom" in configuration):
bloomconf = configuration["Bloom"]
intensity = bloomconf.intensity * 3.0
self.bloom[0].setShaderInput("blend", bloomconf.blendx, bloomconf.blendy, bloomconf.blendz, bloomconf.blendw * 2.0)
@ -293,13 +293,13 @@ class CommonFilters:
self.bloom[3].setShaderInput("intensity", intensity, intensity, intensity, intensity)
if (changed == "VolumetricLighting") or fullrebuild:
if (configuration.has_key("VolumetricLighting")):
if ("VolumetricLighting" in configuration):
config = configuration["VolumetricLighting"]
tcparam = config.density / float(config.numsamples)
self.finalQuad.setShaderInput("vlparams", tcparam, config.decay, config.exposure, 0.0)
if (changed == "AmbientOcclusion") or fullrebuild:
if (configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in configuration):
config = configuration["AmbientOcclusion"]
self.ssao[0].setShaderInput("params1", config.numsamples, -float(config.amount) / config.numsamples, config.radius, 0)
self.ssao[0].setShaderInput("params2", config.strength, config.falloff, 0, 0)
@ -311,7 +311,7 @@ class CommonFilters:
"""Updates the shader inputs that need to be updated every frame.
Normally, you shouldn't call this, it's being called in a task."""
if self.configuration.has_key("VolumetricLighting"):
if "VolumetricLighting" in self.configuration:
caster = self.configuration["VolumetricLighting"].caster
casterpos = Point2()
self.manager.camera.node().getLens().project(caster.getPos(self.manager.camera), casterpos)
@ -320,7 +320,7 @@ class CommonFilters:
return task.cont
def setCartoonInk(self, separation=1, color=(0, 0, 0, 1)):
fullrebuild = (self.configuration.has_key("CartoonInk") == False)
fullrebuild = (("CartoonInk" in self.configuration) == False)
newconfig = FilterConfig()
newconfig.separation = separation
newconfig.color = color
@ -328,7 +328,7 @@ class CommonFilters:
return self.reconfigure(fullrebuild, "CartoonInk")
def delCartoonInk(self):
if (self.configuration.has_key("CartoonInk")):
if ("CartoonInk" in self.configuration):
del self.configuration["CartoonInk"]
return self.reconfigure(True, "CartoonInk")
return True
@ -357,40 +357,40 @@ class CommonFilters:
return self.reconfigure(fullrebuild, "Bloom")
def delBloom(self):
if (self.configuration.has_key("Bloom")):
if ("Bloom" in self.configuration):
del self.configuration["Bloom"]
return self.reconfigure(True, "Bloom")
return True
def setHalfPixelShift(self):
fullrebuild = (self.configuration.has_key("HalfPixelShift") == False)
fullrebuild = (("HalfPixelShift" in self.configuration) == False)
self.configuration["HalfPixelShift"] = 1
return self.reconfigure(fullrebuild, "HalfPixelShift")
def delHalfPixelShift(self):
if (self.configuration.has_key("HalfPixelShift")):
if ("HalfPixelShift" in self.configuration):
del self.configuration["HalfPixelShift"]
return self.reconfigure(True, "HalfPixelShift")
return True
def setViewGlow(self):
fullrebuild = (self.configuration.has_key("ViewGlow") == False)
fullrebuild = (("ViewGlow" in self.configuration) == False)
self.configuration["ViewGlow"] = 1
return self.reconfigure(fullrebuild, "ViewGlow")
def delViewGlow(self):
if (self.configuration.has_key("ViewGlow")):
if ("ViewGlow" in self.configuration):
del self.configuration["ViewGlow"]
return self.reconfigure(True, "ViewGlow")
return True
def setInverted(self):
fullrebuild = (self.configuration.has_key("Inverted") == False)
fullrebuild = (("Inverted" in self.configuration) == False)
self.configuration["Inverted"] = 1
return self.reconfigure(fullrebuild, "Inverted")
def delInverted(self):
if (self.configuration.has_key("Inverted")):
if ("Inverted" in self.configuration):
del self.configuration["Inverted"]
return self.reconfigure(True, "Inverted")
return True
@ -411,7 +411,7 @@ class CommonFilters:
return self.reconfigure(fullrebuild, "VolumetricLighting")
def delVolumetricLighting(self):
if (self.configuration.has_key("VolumetricLighting")):
if ("VolumetricLighting" in self.configuration):
del self.configuration["VolumetricLighting"]
return self.reconfigure(True, "VolumetricLighting")
return True
@ -419,18 +419,18 @@ class CommonFilters:
def setBlurSharpen(self, amount=0.0):
"""Enables the blur/sharpen filter. If the 'amount' parameter is 1.0, it will not have effect.
A value of 0.0 means fully blurred, and a value higher than 1.0 sharpens the image."""
fullrebuild = (self.configuration.has_key("BlurSharpen") == False)
fullrebuild = (("BlurSharpen" in self.configuration) == False)
self.configuration["BlurSharpen"] = amount
return self.reconfigure(fullrebuild, "BlurSharpen")
def delBlurSharpen(self):
if (self.configuration.has_key("BlurSharpen")):
if ("BlurSharpen" in self.configuration):
del self.configuration["BlurSharpen"]
return self.reconfigure(True, "BlurSharpen")
return True
def setAmbientOcclusion(self, numsamples = 16, radius = 0.05, amount = 2.0, strength = 0.01, falloff = 0.000002):
fullrebuild = (self.configuration.has_key("AmbientOcclusion") == False)
fullrebuild = (("AmbientOcclusion" in self.configuration) == False)
newconfig = FilterConfig()
newconfig.numsamples = numsamples
newconfig.radius = radius
@ -441,7 +441,7 @@ class CommonFilters:
return self.reconfigure(fullrebuild, "AmbientOcclusion")
def delAmbientOcclusion(self):
if (self.configuration.has_key("AmbientOcclusion")):
if ("AmbientOcclusion" in self.configuration):
del self.configuration["AmbientOcclusion"]
return self.reconfigure(True, "AmbientOcclusion")
return True

View File

@ -15,7 +15,7 @@ def findDialog(uniqueName):
useful for debugging, to get a pointer to the current onscreen
panel of a particular type.
"""
if DirectDialog.AllDialogs.has_key(uniqueName):
if uniqueName in DirectDialog.AllDialogs:
return DirectDialog.AllDialogs[uniqueName]
return None
@ -27,7 +27,7 @@ def cleanupDialog(uniqueName):
that opening panel A should automatically close panel B, for
instance.
"""
if DirectDialog.AllDialogs.has_key(uniqueName):
if uniqueName in DirectDialog.AllDialogs:
# calling cleanup() will remove it out of the AllDialogs dict
# This way it will get removed from the dict even it we did
# not clean it up using this interface (ie somebody called
@ -330,7 +330,7 @@ class DirectDialog(DirectFrame):
def cleanup(self):
# Remove this panel out of the AllDialogs list
uniqueName = self['dialogName']
if DirectDialog.AllDialogs.has_key(uniqueName):
if uniqueName in DirectDialog.AllDialogs:
del DirectDialog.AllDialogs[uniqueName]
self.destroy()

View File

@ -439,7 +439,7 @@ class DirectGuiBase(DirectObject.DirectObject):
Get current configuration setting for this option
"""
# Return the value of an option, for example myWidget['font'].
if self._optionInfo.has_key(option):
if option in self._optionInfo:
return self._optionInfo[option][DGG._OPT_VALUE]
else:
index = string.find(option, '_')
@ -448,7 +448,7 @@ class DirectGuiBase(DirectObject.DirectObject):
componentOption = option[(index + 1):]
# Expand component alias
if self.__componentAliases.has_key(component):
if component in self.__componentAliases:
component, subComponent = self.__componentAliases[
component]
if subComponent is not None:
@ -457,7 +457,7 @@ class DirectGuiBase(DirectObject.DirectObject):
# Expand option string to write on error
option = component + '_' + componentOption
if self.__componentInfo.has_key(component):
if component in self.__componentInfo:
# Call cget on the component.
componentCget = self.__componentInfo[component][3]
return componentCget(componentOption)
@ -582,7 +582,7 @@ class DirectGuiBase(DirectObject.DirectObject):
# Expand component alias
# Example entry which is an alias for entryField_entry
if self.__componentAliases.has_key(component):
if component in self.__componentAliases:
# component = entryField, subComponent = entry
component, subComponent = self.__componentAliases[component]
if subComponent is not None:
@ -608,7 +608,7 @@ class DirectGuiBase(DirectObject.DirectObject):
return names
def hascomponent(self, component):
return self.__componentInfo.has_key(component)
return component in self.__componentInfo
def destroycomponent(self, name):
# Remove a megawidget component.

View File

@ -124,7 +124,7 @@ if __name__ == "__main__":
command = printDialogValue)
customDialog = DirectDialog(text = 'Pick a number',
buttonTextList = map(str, range(10)),
buttonTextList = [str(i) for i in range(10)],
buttonValueList = range(10),
command = printDialogValue)

View File

@ -22,10 +22,10 @@ class DirectScrolledListItem(DirectButton):
def __init__(self, parent=None, **kw):
assert self.notify.debugStateCall(self)
self.parent = parent
if kw.has_key("command"):
if "command" in kw:
self.nextCommand = kw.get("command")
del kw["command"]
if kw.has_key("extraArgs"):
if "extraArgs" in kw:
self.nextCommandExtraArgs = kw.get("extraArgs")
del kw["extraArgs"]
optiondefs = (
@ -59,7 +59,7 @@ class DirectScrolledList(DirectFrame):
# if 'items' is a list of strings, make a copy for our use
# so we can modify it without mangling the user's list
if kw.has_key('items'):
if 'items' in kw:
for item in kw['items']:
if type(item) != type(''):
break

View File

@ -35,7 +35,7 @@ class DirectWaitBar(DirectFrame):
('barRelief', DGG.FLAT, self.setBarRelief),
('sortOrder', NO_FADE_SORT_INDEX, None),
)
if kw.has_key('text'):
if 'text' in kw:
textoptiondefs = (
('text_pos', (0, -0.025), None),
('text_scale', 0.1, None)

View File

@ -262,7 +262,7 @@ class WebRequestDispatcher(object):
def enableLandingPage(self, enable):
if enable:
if not self.__dict__.has_key("landingPage"):
if "landingPage" not in self.__dict__:
self.landingPage = LandingPage()
self.registerGETHandler("/", self._main, returnsResponse = True, autoSkin = True)
self.registerGETHandler("/services", self._services, returnsResponse = True, autoSkin = True)

View File

@ -292,7 +292,7 @@ def inspectObject(anObject):
def inspectorFor(anObject):
typeName = string.capitalize(type(anObject).__name__) + 'Type'
if _InspectorMap.has_key(typeName):
if typeName in _InspectorMap:
inspectorName = _InspectorMap[typeName]
else:
print "Can't find an inspector for " + typeName
@ -355,7 +355,7 @@ class Inspector:
# self._partsList.append(each)
def initializePartNames(self):
self._partNames = ['up'] + map(lambda each: str(each), self._partsList)
self._partNames = ['up'] + [str(each) for each in self._partsList]
def title(self):
"Subclasses may override."
@ -458,7 +458,7 @@ class DictionaryInspector(Inspector):
if partNumber == 0:
return self.object
key = self.privatePartNumber(partNumber)
if self.object.has_key(key):
if key in self.object:
return self.object[key]
else:
return getattr(self.object, key)

View File

@ -38,7 +38,7 @@ class MetaInterval(CMetaInterval):
#else:
# Look for the name in the keyword params.
if kw.has_key('name'):
if 'name' in kw:
name = kw['name']
del kw['name']
@ -52,10 +52,10 @@ class MetaInterval(CMetaInterval):
autoPause = 0
autoFinish = 0
if kw.has_key('autoPause'):
if 'autoPause' in kw:
autoPause = kw['autoPause']
del kw['autoPause']
if kw.has_key('autoFinish'):
if 'autoFinish' in kw:
autoFinish = kw['autoFinish']
del kw['autoFinish']
@ -63,7 +63,7 @@ class MetaInterval(CMetaInterval):
# appear to have for the purposes of computing the start time
# for subsequent intervals in a sequence or track.
self.phonyDuration = -1
if kw.has_key('duration'):
if 'duration' in kw:
self.phonyDuration = kw['duration']
del kw['duration']

View File

@ -91,7 +91,7 @@ class ObjectPropUI(wx.Panel):
value = self.getValue()
frame = self.parent.editor.ui.animUI.curFrame
if self.parent.editor.animMgr.keyFramesInfo.has_key((objUID,propertyName)):
if (objUID, propertyName) in self.parent.editor.animMgr.keyFramesInfo:
for i in range(len(self.parent.editor.animMgr.keyFramesInfo[(objUID,propertyName)])):
if self.parent.editor.animMgr.keyFramesInfo[(objUID,propertyName)][i][AG.FRAME] == frame:
del self.parent.editor.animMgr.keyFramesInfo[(objUID,propertyName)][i]
@ -239,8 +239,8 @@ class ObjectPropUITime(wx.Panel):
hSizer = wx.BoxSizer(wx.HORIZONTAL)
self.uiAmPm = wx.Choice(self.uiPane, -1, choices=['AM', 'PM'])
self.uiHour = wx.Choice(self.uiPane, -1, choices=map(lambda x : str(x), range(1, 13)))
self.uiMin = wx.Choice(self.uiPane, -1, choices=map(lambda x : str(x), range(0, 60, 15)))
self.uiHour = wx.Choice(self.uiPane, -1, choices=[str(x) for x in range(1, 13)])
self.uiMin = wx.Choice(self.uiPane, -1, choices=[str(x) for x in range(0, 60, 15)])
hSizer.Add(self.uiAmPm)
hSizer.Add(self.uiHour)

View File

@ -39,9 +39,9 @@ def archiveFilter(info):
# Somewhat hacky, but it's the only way
# permissions can work on a Windows box.
if info.type != tarfile.DIRTYPE and '.' in info.name.rsplit('/', 1)[-1]:
info.mode = 0644
info.mode = 0o644
else:
info.mode = 0755
info.mode = 0o755
return info
@ -53,8 +53,8 @@ class TarInfoRoot(tarfile.TarInfo):
gid = property(lambda self: 0, lambda self, x: None)
uname = property(lambda self: "root", lambda self, x: None)
gname = property(lambda self: "root", lambda self, x: None)
mode = property(lambda self: 0644 if self.type != tarfile.DIRTYPE and \
'.' in self.name.rsplit('/', 1)[-1] else 0755,
mode = property(lambda self: 0o644 if self.type != tarfile.DIRTYPE and \
'.' in self.name.rsplit('/', 1)[-1] else 0o755,
lambda self, x: None)
# On OSX, the root group is named "wheel".
@ -186,7 +186,7 @@ class Standalone:
ohandle.close()
phandle.close()
os.chmod(output.toOsSpecific(), 0755)
os.chmod(output.toOsSpecific(), 0o755)
def getExtraFiles(self, platform):
""" Returns a list of extra files that will need to be included
@ -550,7 +550,7 @@ class Installer:
mf = Multifile()
# Make sure that it isn't mounted before altering it, just to be safe
vfs.unmount(archive)
os.chmod(archive.toOsSpecific(), 0644)
os.chmod(archive.toOsSpecific(), 0o644)
if not mf.openReadWrite(archive):
Installer.notify.warning("Failed to open archive %s" % (archive))
continue
@ -575,7 +575,7 @@ class Installer:
# archive.unlink()
#else:
mf.close()
try: os.chmod(archive.toOsSpecific(), 0444)
try: os.chmod(archive.toOsSpecific(), 0o444)
except: pass
# Write out our own contents.xml file.

View File

@ -205,9 +205,9 @@ class FileSpec:
# On Windows, we have to change the file to read-write before
# we can successfully update its timestamp.
try:
os.chmod(pathname.toOsSpecific(), 0755)
os.chmod(pathname.toOsSpecific(), 0o755)
os.utime(pathname.toOsSpecific(), (st.st_atime, self.timestamp))
os.chmod(pathname.toOsSpecific(), 0555)
os.chmod(pathname.toOsSpecific(), 0o555)
except OSError:
pass

View File

@ -175,7 +175,7 @@ class PackageInfo:
# Return the size of plan A, assuming it will work.
plan = self.installPlans[0]
size = sum(map(lambda step: step.getEffort(), plan))
size = sum([step.getEffort() for step in plan])
return size
@ -313,7 +313,7 @@ class PackageInfo:
filename = Filename(self.getPackageDir(), self.descFileBasename)
# Now that we've written the desc file, make it read-only.
os.chmod(filename.toOsSpecific(), 0444)
os.chmod(filename.toOsSpecific(), 0o444)
if not self.__readDescFile():
# Weird, it passed the hash check, but we still can't read
@ -688,7 +688,7 @@ class PackageInfo:
installPlans = self.installPlans
self.installPlans = None
for plan in installPlans:
self.totalPlanSize = sum(map(lambda step: step.getEffort(), plan))
self.totalPlanSize = sum([step.getEffort() for step in plan])
self.totalPlanCompleted = 0
self.downloadProgress = 0
@ -832,7 +832,7 @@ class PackageInfo:
if bytesStarted:
self.notify.info("Resuming %s after %s bytes already downloaded" % (url, bytesStarted))
# Make sure the file is writable.
os.chmod(targetPathname.toOsSpecific(), 0644)
os.chmod(targetPathname.toOsSpecific(), 0o644)
channel.beginGetSubdocument(request, bytesStarted, 0)
else:
# No partial download possible; get the whole file.
@ -980,7 +980,7 @@ class PackageInfo:
yield self.stepFailed; return
# Now that we've verified the archive, make it read-only.
os.chmod(targetPathname.toOsSpecific(), 0444)
os.chmod(targetPathname.toOsSpecific(), 0o444)
# Now we can safely remove the compressed archive.
sourcePathname.unlink()
@ -1032,7 +1032,7 @@ class PackageInfo:
continue
# Make sure it's executable, and not writable.
os.chmod(targetPathname.toOsSpecific(), 0555)
os.chmod(targetPathname.toOsSpecific(), 0o555)
step.bytesDone += file.size
self.__updateStepProgress(step)

View File

@ -427,7 +427,7 @@ class Packager:
self.compressionLevel = 6
# Every p3dapp requires panda3d.
if 'panda3d' not in map(lambda p: p.packageName, self.requires):
if 'panda3d' not in [p.packageName for p in self.requires]:
assert not self.packager.currentPackage
self.packager.currentPackage = self
self.packager.do_require('panda3d')
@ -726,7 +726,7 @@ class Packager:
if self.p3dApplication:
# No patches for an application; just move it into place.
# Make the application file executable.
os.chmod(self.packageFullpath.toOsSpecific(), 0755)
os.chmod(self.packageFullpath.toOsSpecific(), 0o755)
else:
self.readDescFile()
self.packageSeq += 1
@ -2206,7 +2206,7 @@ class Packager:
# returned, so they will persist beyond the lifespan of the
# config variable.
cvar = ConfigVariableSearchPath('pdef-path')
self.installSearch = map(Filename, cvar.getDirectories())
self.installSearch = list(map(Filename, cvar.getDirectories()))
# The system PATH, for searching dll's and exe's.
self.executablePath = DSearchPath()
@ -2938,7 +2938,7 @@ class Packager:
tuples.append((version, file))
tuples.sort(reverse = True)
return map(lambda t: t[1], tuples)
return [t[1] for t in tuples]
def __sortPackageInfos(self, packages):
""" Given a list of PackageInfos retrieved from a Host, sorts
@ -2951,7 +2951,7 @@ class Packager:
tuples.append((version, file))
tuples.sort(reverse = True)
return map(lambda t: t[1], tuples)
return [t[1] for t in tuples]
def __makeVersionTuple(self, version):
""" Converts a version string into a tuple for sorting, by

View File

@ -204,7 +204,7 @@ def makePackedApp(args):
# Pre-require panda3d, to give a less-confusing error message
# if one of our requirements pulls in a wrong version of
# panda3d.
if 'panda3d' not in map(lambda t: t[0], requires):
if 'panda3d' not in [t[0] for t in requires]:
packager.do_require('panda3d')
for name, version, host in requires:

View File

@ -441,7 +441,7 @@ def makeInstaller():
if not os.path.exists(dst_panda3dapp): os.makedirs(os.path.dirname(dst_panda3dapp))
shutil.copytree(pluginFiles[npapi], dst_npapi)
shutil.copyfile(pluginFiles[panda3d], dst_panda3d)
os.chmod(dst_panda3d, 0755)
os.chmod(dst_panda3d, 0o755)
shutil.copytree(pluginFiles[panda3dapp], dst_panda3dapp)
tmpresdir = tempfile.mktemp('', 'p3d-resources')

View File

@ -73,7 +73,7 @@ def makeBundle(startDir):
shutil.copyfile(icons.toOsSpecific(), iconFilename.toOsSpecific())
print panda3d_mac, exeFilename
shutil.copyfile(panda3d_mac.toOsSpecific(), exeFilename.toOsSpecific())
os.chmod(exeFilename.toOsSpecific(), 0755)
os.chmod(exeFilename.toOsSpecific(), 0o755)
# All done!
bundleFilename.touch()

View File

@ -96,7 +96,7 @@ def identify(name, xtrapath=None):
else:
if xtrapath is None:
xtra = []
elif _pcache.has_key(id(xtrapath)):
elif id(xtrapath) in _pcache:
xtra = _pcache[id(xtrapath)]
else:
xtra = expand(xtrapath)

View File

@ -218,7 +218,7 @@ class ModuleFinder:
else:
self.msgout(3, "import_module ->", m)
return m
if self.badmodules.has_key(fqname):
if fqname in self.badmodules:
self.msgout(3, "import_module -> None")
self.badmodules[fqname][parent.__name__] = None
return None
@ -275,24 +275,24 @@ class ModuleFinder:
i = i+2
if op == IMPORT_NAME:
name = lastname = co.co_names[oparg]
if not self.badmodules.has_key(lastname):
if lastname not in self.badmodules:
try:
self.import_hook(name, m)
except ImportError, msg:
self.msg(2, "ImportError:", str(msg))
if not self.badmodules.has_key(name):
if name not in self.badmodules:
self.badmodules[name] = {}
self.badmodules[name][m.__name__] = None
elif op == IMPORT_FROM:
name = co.co_names[oparg]
assert lastname is not None
if not self.badmodules.has_key(lastname):
if lastname not in self.badmodules:
try:
self.import_hook(lastname, m, [name])
except ImportError, msg:
self.msg(2, "ImportError:", str(msg))
fullname = lastname + "." + name
if not self.badmodules.has_key(fullname):
if fullname not in self.badmodules:
self.badmodules[fullname] = {}
self.badmodules[fullname][m.__name__] = None
else:
@ -316,7 +316,7 @@ class ModuleFinder:
return m
def add_module(self, fqname):
if self.modules.has_key(fqname):
if fqname in self.modules:
return self.modules[fqname]
self.modules[fqname] = m = Module(fqname)
return m

View File

@ -18,7 +18,7 @@ def makeresource(name, xtrapath=None):
when the module archive.py was desired."""
typ, nm, fullname = finder.identify(name, xtrapath)
fullname = os.path.normpath(fullname)
if _cache.has_key(fullname):
if fullname in _cache:
return _cache[fullname]
elif typ in (finder.SCRIPT, finder.GSCRIPT):
rsrc = scriptresource(nm, fullname)

View File

@ -139,7 +139,7 @@ class Audio3DManager:
"""
Get the velocity of the sound.
"""
if (self.vel_dict.has_key(sound)):
if (sound in self.vel_dict):
vel = self.vel_dict[sound]
if (vel!=None):
return vel
@ -196,7 +196,7 @@ class Audio3DManager:
# the object any more
del self.sound_dict[known_object]
if not self.sound_dict.has_key(object):
if object not in self.sound_dict:
self.sound_dict[object] = []
self.sound_dict[object].append(sound)
@ -222,7 +222,7 @@ class Audio3DManager:
"""
returns a list of sounds attached to an object
"""
if not self.sound_dict.has_key(object):
if object not in self.sound_dict:
return []
sound_list = []
sound_list.extend(self.sound_dict[object])

View File

@ -20,7 +20,7 @@ class Factory:
return self._type2ctor[type](*args, **kwArgs)
def _registerType(self, type, ctor):
if self._type2ctor.has_key(type):
if type in self._type2ctor:
self.notify.debug('replacing %s ctor %s with %s' %
(type, self._type2ctor[type], ctor))
self._type2ctor[type] = ctor

View File

@ -61,10 +61,7 @@ import bisect
__report_indent = 3
from direct.directutil import Verify
# Don't import libpandaexpressModules, which doesn't get built until
# genPyCode.
import direct.extensions_native.extension_native_helpers
from libpandaexpress import ConfigVariableBool
from panda3d.core import ConfigVariableBool
ScalarTypes = (types.FloatType, types.IntType, types.LongType)

View File

@ -457,7 +457,7 @@ class VFSSharedLoader:
# Also set this special symbol, which records that this is a
# shared package, and also lists the paths we have already
# loaded.
mod._vfs_shared_path = vfs_shared_path + map(lambda l: l.dir_path, self.loaders)
mod._vfs_shared_path = vfs_shared_path + [l.dir_path for l in self.loaders]
return mod

View File

@ -18,7 +18,7 @@ def newimport(*args, **kw):
fPrint = 0
name = args[0]
# Only print the name if we have not imported this before
if not sys.modules.has_key(name):
if name not in sys.modules:
print (" "*indentLevel + "import " + args[0])
fPrint = 1
indentLevel += 1

View File

@ -627,7 +627,7 @@ class TexMemWatcher(DirectObject):
self.repack()
else:
overflowCount = sum(map(lambda tp: tp.overflowed, self.texPlacements.keys()))
overflowCount = sum([tp.overflowed for tp in self.texPlacements.keys()])
if totalSize <= self.limit and overflowCount:
# Shouldn't be overflowing any more. Better repack.
self.repack()

View File

@ -216,8 +216,7 @@ class DirectSessionPanel(AppShell):
Label(drFrame, text = 'Display Region',
font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
nameList = map(lambda x: 'Display Region ' + repr(x),
range(len(base.direct.drList)))
nameList = ['Display Region ' + repr(x) for x in range(len(base.direct.drList))]
self.drMenu = Pmw.ComboBox(
drFrame, labelpos = W, label_text = 'Display Region:',
entry_width = 20,
@ -726,7 +725,7 @@ class DirectSessionPanel(AppShell):
else:
# Generate a unique name for the dict
dictName = name + '-' + repr(nodePath.id())
if not dict.has_key(dictName):
if dictName not in dict:
# Update combo box to include new item
names.append(dictName)
listbox = menu.component('scrolledlist')

View File

@ -24,7 +24,7 @@ def inspect(anObject):
def inspectorFor(anObject):
typeName = string.capitalize(type(anObject).__name__) + 'Type'
if _InspectorMap.has_key(typeName):
if typeName in _InspectorMap:
inspectorName = _InspectorMap[typeName]
else:
print "Can't find an inspector for " + typeName
@ -92,7 +92,7 @@ class Inspector:
# self._partsList.append(each)
def initializePartNames(self):
self._partNames = ['up'] + map(lambda each: str(each), self._partsList)
self._partNames = ['up'] + [str(each) for each in self._partsList]
def title(self):
"Subclasses may override."
@ -195,7 +195,7 @@ class DictionaryInspector(Inspector):
if partNumber == 0:
return self.object
key = self.privatePartNumber(partNumber)
if self.object.has_key(key):
if key in self.object:
return self.object[key]
else:
return getattr(self.object, key)

View File

@ -1248,7 +1248,7 @@ class MopathRecorder(AppShell, DirectObject):
else:
# Generate a unique name for the dict
dictName = name + '-' + repr(nodePath.id())
if not dict.has_key(dictName):
if dictName not in dict:
# Update combo box to include new item
names.append(dictName)
listbox = menu.component('scrolledlist')

View File

@ -1132,7 +1132,7 @@ class ParticlePanel(AppShell):
self.particlesLabelMenu.add_separator()
# Add in a checkbutton for each effect (to toggle on/off)
particles = self.particleEffect.getParticlesList()
names = map(lambda x: x.getName(), particles)
names = [x.getName() for x in particles]
names.sort()
for name in names:
particle = self.particleEffect.getParticlesNamed(name)
@ -1157,7 +1157,7 @@ class ParticlePanel(AppShell):
self.forceGroupLabelMenu.add_separator()
# Add in a checkbutton for each effect (to toggle on/off)
forceGroupList = self.particleEffect.getForceGroupList()
names = map(lambda x: x.getName(), forceGroupList)
names = [x.getName() for x in forceGroupList]
names.sort()
for name in names:
force = self.particleEffect.getForceGroupNamed(name)

View File

@ -510,7 +510,7 @@ class Placer(AppShell):
else:
# Generate a unique name for the dict
dictName = name + '-' + repr(nodePath.id())
if not dict.has_key(dictName):
if dictName not in dict:
# Update combo box to include new item
names.append(dictName)
listbox = menu.component('scrolledlist')

View File

@ -293,8 +293,7 @@ class EntryScaleGroup(Pmw.MegaToplevel):
DEFAULT_DIM = 1
# Default value depends on *actual* group size, test for user input
DEFAULT_VALUE = [0.0] * kw.get('dim', DEFAULT_DIM)
DEFAULT_LABELS = map(lambda x: 'v[%d]' % x,
range(kw.get('dim', DEFAULT_DIM)))
DEFAULT_LABELS = ['v[%d]' % x for x in range(kw.get('dim', DEFAULT_DIM))]
#define the megawidget options
INITOPT = Pmw.INITOPT

View File

@ -218,8 +218,7 @@ class FloaterGroup(Pmw.MegaToplevel):
DEFAULT_DIM = 1
# Default value depends on *actual* group size, test for user input
DEFAULT_VALUE = [0.0] * kw.get('dim', DEFAULT_DIM)
DEFAULT_LABELS = map(lambda x: 'v[%d]' % x,
range(kw.get('dim', DEFAULT_DIM)))
DEFAULT_LABELS = ['v[%d]' % x for x in range(kw.get('dim', DEFAULT_DIM))]
#define the megawidget options
INITOPT = Pmw.INITOPT

View File

@ -262,7 +262,7 @@ class SliderWidget(Pmw.MegaWidget):
self.initialiseoptions(SliderWidget)
# Adjust relief
if not kw.has_key('relief'):
if 'relief' not in kw:
if self['style'] == VALUATOR_FULL:
self['relief'] = FLAT

View File

@ -227,7 +227,7 @@ class TreeNode:
self.kidKeys = []
for item in sublist:
key = item.GetKey()
if fUseCachedChildren and self.children.has_key(key):
if fUseCachedChildren and key in self.children:
child = self.children[key]
else:
child = TreeNode(self.canvas, self, item, self.menuList)
@ -291,7 +291,7 @@ class TreeNode:
sublist.sort(compareText)
for item in sublist:
key = item.GetKey()
if fUseCachedChildren and self.children.has_key(key):
if fUseCachedChildren and key in self.children:
child = self.children[key]
else:
child = TreeNode(self.canvas, self, item, self.menuList)
@ -452,7 +452,7 @@ class TreeNode:
key = item.GetKey()
# Use existing child or create new TreeNode if none exists
if self.children.has_key(key):
if key in self.children:
child = self.children[key]
else:
child = TreeNode(self.canvas, self, item, self.menuList)

View File

@ -89,7 +89,7 @@ class Valuator(Pmw.MegaWidget):
self.packValuator()
# Set reset value if none specified
if not kw.has_key('resetValue'):
if 'resetValue' not in kw:
self['resetValue'] = self['value']
if self['fAdjustable']:
@ -351,8 +351,7 @@ class ValuatorGroup(Pmw.MegaWidget):
DEFAULT_DIM = 1
# Default value depends on *actual* group size, test for user input
DEFAULT_VALUE = [0.0] * kw.get('dim', DEFAULT_DIM)
DEFAULT_LABELS = map(lambda x: 'v[%d]' % x,
range(kw.get('dim', DEFAULT_DIM)))
DEFAULT_LABELS = ['v[%d]' % x for x in range(kw.get('dim', DEFAULT_DIM))]
#define the megawidget options
INITOPT = Pmw.INITOPT
@ -486,8 +485,7 @@ class ValuatorGroupPanel(Pmw.MegaToplevel):
DEFAULT_DIM = 1
# Default value depends on *actual* group size, test for user input
DEFAULT_VALUE = [0.0] * kw.get('dim', DEFAULT_DIM)
DEFAULT_LABELS = map(lambda x: 'v[%d]' % x,
range(kw.get('dim', DEFAULT_DIM)))
DEFAULT_LABELS = ['v[%d]' % x for x in range(kw.get('dim', DEFAULT_DIM))]
#define the megawidget options
INITOPT = Pmw.INITOPT

View File

@ -19,8 +19,7 @@ class VectorEntry(Pmw.MegaWidget):
DEFAULT_DIM = 3
# Default value depends on *actual* vector size, test for user input
DEFAULT_VALUE = [0.0] * kw.get('dim', DEFAULT_DIM)
DEFAULT_LABELS = map(lambda x: 'v[%d]' % x,
range(kw.get('dim', DEFAULT_DIM)))
DEFAULT_LABELS = ['v[%d]' % x for x in range(kw.get('dim', DEFAULT_DIM))]
# Process options
INITOPT = Pmw.INITOPT

View File

@ -126,26 +126,26 @@ class WxPandaShell(WxAppShell):
base.startDirect(fWantTk = 0, fWantWx = 0)
base.direct.disableMouseEvents()
newMouseEvents = map(lambda x: "_le_per_%s"%x, base.direct.mouseEvents) +\
map(lambda x: "_le_fro_%s"%x, base.direct.mouseEvents) +\
map(lambda x: "_le_lef_%s"%x, base.direct.mouseEvents) +\
map(lambda x: "_le_top_%s"%x, base.direct.mouseEvents)
newMouseEvents = ["_le_per_%s"%x for x in base.direct.mouseEvents] +\
["_le_fro_%s"%x for x in base.direct.mouseEvents] +\
["_le_lef_%s"%x for x in base.direct.mouseEvents] +\
["_le_top_%s"%x for x in base.direct.mouseEvents]
base.direct.mouseEvents = newMouseEvents
base.direct.enableMouseEvents()
base.direct.disableKeyEvents()
keyEvents = map(lambda x: "_le_per_%s"%x, base.direct.keyEvents) +\
map(lambda x: "_le_fro_%s"%x, base.direct.keyEvents) +\
map(lambda x: "_le_lef_%s"%x, base.direct.keyEvents) +\
map(lambda x: "_le_top_%s"%x, base.direct.keyEvents)
keyEvents = ["_le_per_%s"%x for x in base.direct.keyEvents] +\
["_le_fro_%s"%x for x in base.direct.keyEvents] +\
["_le_lef_%s"%x for x in base.direct.keyEvents] +\
["_le_top_%s"%x for x in base.direct.keyEvents]
base.direct.keyEvents = keyEvents
base.direct.enableKeyEvents()
base.direct.disableModifierEvents()
modifierEvents = map(lambda x: "_le_per_%s"%x, base.direct.modifierEvents) +\
map(lambda x: "_le_fro_%s"%x, base.direct.modifierEvents) +\
map(lambda x: "_le_lef_%s"%x, base.direct.modifierEvents) +\
map(lambda x: "_le_top_%s"%x, base.direct.modifierEvents)
modifierEvents = ["_le_per_%s"%x for x in base.direct.modifierEvents] +\
["_le_fro_%s"%x for x in base.direct.modifierEvents] +\
["_le_lef_%s"%x for x in base.direct.modifierEvents] +\
["_le_top_%s"%x for x in base.direct.modifierEvents]
base.direct.modifierEvents = modifierEvents
base.direct.enableModifierEvents()