From ac1223d0da6c10bbb883ad244c238254de979f29 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 19 Mar 2010 10:32:09 +0000 Subject: [PATCH] Ditch stuff like has_key and backticks --- direct/src/actor/Actor.py | 2 +- direct/src/cluster/ClusterClient.py | 4 +- .../src/directdevices/DirectDeviceManager.py | 10 +-- direct/src/directdevices/DirectFastrak.py | 4 +- direct/src/directdevices/DirectJoybox.py | 4 +- direct/src/directdevices/DirectRadamec.py | 2 +- direct/src/directnotify/DirectNotify.py | 2 +- direct/src/directtools/DirectCameraControl.py | 18 ++--- direct/src/directtools/DirectLights.py | 8 +- direct/src/directtools/DirectSelection.py | 2 +- direct/src/distributed/AsyncRequest.py | 2 +- direct/src/distributed/DoCollectionManager.py | 6 +- .../extension_native_helpers.py | 2 +- direct/src/ffi/DoGenPyCode.py | 2 +- direct/src/ffi/FFIExternalObject.py | 8 +- direct/src/ffi/FFIInterrogateDatabase.py | 8 +- direct/src/ffi/FFIOverload.py | 20 ++--- direct/src/ffi/FFISpecs.py | 2 +- direct/src/ffi/FFITypes.py | 2 +- direct/src/gui/DirectDialog.py | 6 +- direct/src/gui/DirectFrame.py | 6 +- direct/src/gui/DirectScrolledList.py | 4 +- direct/src/http/webAIInspector.py | 12 +-- direct/src/interval/FunctionInterval.py | 2 +- direct/src/interval/LerpInterval.py | 4 +- direct/src/interval/ProjectileInterval.py | 8 +- direct/src/p3d/AppRunner.py | 2 +- direct/src/particles/Particles.py | 52 ++++++------ direct/src/pyinst/Builder.py | 6 +- direct/src/pyinst/carchive.py | 4 +- direct/src/pyinst/carchive_rt.py | 4 +- direct/src/pyinst/ltoc.py | 2 +- direct/src/pyinst/modulefinder.py | 8 +- direct/src/pyinst/resource.py | 2 +- direct/src/showbase/BufferViewer.py | 14 ++-- direct/src/showbase/DistancePhasedNode.py | 8 +- direct/src/showbase/EventManager.py | 4 +- direct/src/showbase/Messenger.py | 40 +++++----- direct/src/showbase/ProfileSession.py | 2 +- direct/src/showbase/PythonUtil.py | 80 +++++++++---------- direct/src/showbase/ShowBase.py | 2 +- direct/src/stdpy/glob.py | 4 +- direct/src/task/Task.py | 2 +- direct/src/tkpanels/DirectSessionPanel.py | 4 +- direct/src/tkpanels/FSMInspector.py | 2 +- direct/src/tkpanels/Inspector.py | 14 ++-- direct/src/tkpanels/MopathRecorder.py | 10 +-- direct/src/tkpanels/ParticlePanel.py | 52 ++++++------ direct/src/tkpanels/Placer.py | 2 +- direct/src/tkwidgets/AppShell.py | 2 +- direct/src/tkwidgets/EntryScale.py | 8 +- direct/src/tkwidgets/Tree.py | 2 +- 52 files changed, 241 insertions(+), 241 deletions(-) diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index 0627daff76..d5c9fd0545 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -476,7 +476,7 @@ class Actor(DirectObject, NodePath): print 'LOD:', lodName for partName, bundle, animInfo in lodInfo: print ' Part:', partName - print ' Bundle:', `bundle` + print ' Bundle:', repr(bundle) for animName, file, animControl in animInfo: print ' Anim:', animName print ' File:', file diff --git a/direct/src/cluster/ClusterClient.py b/direct/src/cluster/ClusterClient.py index b82fd3e38d..1fe8d9569d 100644 --- a/direct/src/cluster/ClusterClient.py +++ b/direct/src/cluster/ClusterClient.py @@ -263,7 +263,7 @@ class ClusterClient(DirectObject.DirectObject): def getNodePathFindCmd(self, nodePath): import string - pathString = `nodePath` + pathString = repr(nodePath) index = string.find(pathString, '/') if index != -1: rootName = pathString[:index] @@ -274,7 +274,7 @@ class ClusterClient(DirectObject.DirectObject): def getNodePathName(self, nodePath): import string - pathString = `nodePath` + pathString = repr(nodePath) index = string.find(pathString, '/') if index != -1: name = pathString[index+1:] diff --git a/direct/src/directdevices/DirectDeviceManager.py b/direct/src/directdevices/DirectDeviceManager.py index 983d0f5fb2..0c435849f1 100644 --- a/direct/src/directdevices/DirectDeviceManager.py +++ b/direct/src/directdevices/DirectDeviceManager.py @@ -48,7 +48,7 @@ class DirectButtons(ButtonNode, DirectObject): # Keep track of number of buttons created DirectButtons.buttonCount += 1 # Create a unique name for this button object - self.name = 'DirectButtons-' + `DirectButtons.buttonCount` + self.name = 'DirectButtons-' + repr(DirectButtons.buttonCount) # Create a new button node for the given device ButtonNode.__init__(self, vrpnClient, device) # Attach node to data graph @@ -86,7 +86,7 @@ class DirectAnalogs(AnalogNode, DirectObject): # Keep track of number of analogs created DirectAnalogs.analogCount += 1 # Create a unique name for this analog object - self.name = 'DirectAnalogs-' + `DirectAnalogs.analogCount` + self.name = 'DirectAnalogs-' + repr(DirectAnalogs.analogCount) # Create a new analog node for the given device AnalogNode.__init__(self, vrpnClient, device) # Attach node to data graph @@ -182,7 +182,7 @@ class DirectTracker(TrackerNode, DirectObject): # Keep track of number of trackers created DirectTracker.trackerCount += 1 # Create a unique name for this tracker object - self.name = 'DirectTracker-' + `DirectTracker.trackerCount` + self.name = 'DirectTracker-' + repr(DirectTracker.trackerCount) # Create a new tracker node for the given device TrackerNode.__init__(self, vrpnClient, device) # Attach node to data graph @@ -209,7 +209,7 @@ class DirectDials(DialNode, DirectObject): # Keep track of number of dials created DirectDials.dialCount += 1 # Create a unique name for this dial object - self.name = 'DirectDials-' + `DirectDials.dialCount` + self.name = 'DirectDials-' + repr(DirectDials.dialCount) # Create a new dial node for the given device DialNode.__init__(self, vrpnClient, device) # Attach node to data graph @@ -250,7 +250,7 @@ class DirectTimecodeReader(AnalogNode, DirectObject): DirectTimecodeReader.timecodeReaderCount += 1 # Create a unique name for this dial object self.name = ('DirectTimecodeReader-' + - `DirectTimecodeReader.timecodeReaderCount`) + repr(DirectTimecodeReader.timecodeReaderCount)) # Initialize components of timecode self.frames = 0 self.seconds = 0 diff --git a/direct/src/directdevices/DirectFastrak.py b/direct/src/directdevices/DirectFastrak.py index 00fc4b2811..4f046329a0 100644 --- a/direct/src/directdevices/DirectFastrak.py +++ b/direct/src/directdevices/DirectFastrak.py @@ -26,7 +26,7 @@ class DirectFastrak(DirectObject): base.direct.deviceManager = DirectDeviceManager() # Set name - self.name = 'Fastrak-' + `DirectFastrak.fastrakCount` + self.name = 'Fastrak-' + repr(DirectFastrak.fastrakCount) self.deviceNo = DirectFastrak.fastrakCount DirectFastrak.fastrakCount += 1 @@ -64,5 +64,5 @@ class DirectFastrak(DirectObject): self.trackerPos = Vec3(3.280839895013123 * pos[2], 3.280839895013123 * pos[1], 3.280839895013123 * pos[0]) - self.notify.debug("Tracker(%d) Pos = %s" % (self.deviceNo, `self.trackerPos`)) + self.notify.debug("Tracker(%d) Pos = %s" % (self.deviceNo, repr(self.trackerPos))) diff --git a/direct/src/directdevices/DirectJoybox.py b/direct/src/directdevices/DirectJoybox.py index ccb05d07a8..ac5518ed3e 100644 --- a/direct/src/directdevices/DirectJoybox.py +++ b/direct/src/directdevices/DirectJoybox.py @@ -46,7 +46,7 @@ class DirectJoybox(DirectObject): base.direct.deviceManager = DirectDeviceManager() # Set name DirectJoybox.joyboxCount += 1 - self.name = 'Joybox-' + `DirectJoybox.joyboxCount` + self.name = 'Joybox-' + repr(DirectJoybox.joyboxCount) # Get buttons and analogs self.device = device self.analogs = base.direct.deviceManager.createAnalogs(self.device) @@ -130,7 +130,7 @@ class DirectJoybox(DirectObject): def getRefCS(self): return self.refCS def getEventName(self, index): - return self.name + '-button-' + `index` + return self.name + '-button-' + repr(index) def setXyzMultiplier(self, multiplier): DirectJoybox.xyzMultiplier = multiplier def getXyzMultiplier(self): diff --git a/direct/src/directdevices/DirectRadamec.py b/direct/src/directdevices/DirectRadamec.py index 0d69bb56a0..65880be00f 100644 --- a/direct/src/directdevices/DirectRadamec.py +++ b/direct/src/directdevices/DirectRadamec.py @@ -26,7 +26,7 @@ class DirectRadamec(DirectObject): if base.direct.deviceManager == None: base.direct.deviceManager = DirectDeviceManager() # Set name - self.name = 'Radamec-' + `DirectRadamec.radamecCount` + self.name = 'Radamec-' + repr(DirectRadamec.radamecCount) DirectRadamec.radamecCount += 1 # Get analogs self.device = device diff --git a/direct/src/directnotify/DirectNotify.py b/direct/src/directnotify/DirectNotify.py index c1061ebd1e..c5eb4445a3 100644 --- a/direct/src/directnotify/DirectNotify.py +++ b/direct/src/directnotify/DirectNotify.py @@ -48,7 +48,7 @@ class DirectNotify: Make a new notify category named categoryName. Return new category if no such category exists, else return existing category """ - if (not self.__categories.has_key(categoryName)): + if (categoryName not in self.__categories): self.__categories[categoryName] = Notifier.Notifier(categoryName, logger) self.setDconfigLevel(categoryName) return (self.getCategory(categoryName)) diff --git a/direct/src/directtools/DirectCameraControl.py b/direct/src/directtools/DirectCameraControl.py index 04f2a489f5..43c2a5dc54 100644 --- a/direct/src/directtools/DirectCameraControl.py +++ b/direct/src/directtools/DirectCameraControl.py @@ -55,14 +55,14 @@ class DirectCameraControl(DirectObject): ## ['n', self.pickNextCOA], ## ['u', self.orbitUprightCam], ## ['shift-u', self.uprightCam], -## [`1`, self.spawnMoveToView, 1], -## [`2`, self.spawnMoveToView, 2], -## [`3`, self.spawnMoveToView, 3], -## [`4`, self.spawnMoveToView, 4], -## [`5`, self.spawnMoveToView, 5], -## [`6`, self.spawnMoveToView, 6], -## [`7`, self.spawnMoveToView, 7], -## [`8`, self.spawnMoveToView, 8], +## [repr(1), self.spawnMoveToView, 1], +## [repr(2), self.spawnMoveToView, 2], +## [repr(3), self.spawnMoveToView, 3], +## [repr(4), self.spawnMoveToView, 4], +## [repr(5), self.spawnMoveToView, 5], +## [repr(6), self.spawnMoveToView, 6], +## [repr(7), self.spawnMoveToView, 7], +## [repr(8), self.spawnMoveToView, 8], ## ['9', self.swingCamAboutWidget, -90.0, t], ## ['0', self.swingCamAboutWidget, 90.0, t], ## ['`', self.removeManipulateCameraTask], @@ -524,7 +524,7 @@ class DirectCameraControl(DirectObject): # MRM: Would be nice to be able to control this # At least display it dist = pow(10.0, self.nullHitPointCount) - base.direct.message('COA Distance: ' + `dist`) + base.direct.message('COA Distance: ' + repr(dist)) coa.set(0, dist, 0) # Compute COA Dist coaDist = Vec3(coa - ZERO_POINT).length() diff --git a/direct/src/directtools/DirectLights.py b/direct/src/directtools/DirectLights.py index 4a493d779d..59eba21947 100644 --- a/direct/src/directtools/DirectLights.py +++ b/direct/src/directtools/DirectLights.py @@ -60,19 +60,19 @@ class DirectLights(NodePath): type = type.lower() if type == 'ambient': self.ambientCount += 1 - light = AmbientLight('ambient-' + `self.ambientCount`) + light = AmbientLight('ambient-' + repr(self.ambientCount)) light.setColor(VBase4(.3, .3, .3, 1)) elif type == 'directional': self.directionalCount += 1 - light = DirectionalLight('directional-' + `self.directionalCount`) + light = DirectionalLight('directional-' + repr(self.directionalCount)) light.setColor(VBase4(1)) elif type == 'point': self.pointCount += 1 - light = PointLight('point-' + `self.pointCount`) + light = PointLight('point-' + repr(self.pointCount)) light.setColor(VBase4(1)) elif type == 'spot': self.spotCount += 1 - light = Spotlight('spot-' + `self.spotCount`) + light = Spotlight('spot-' + repr(self.spotCount)) light.setColor(VBase4(1)) light.setLens(PerspectiveLens()) else: diff --git a/direct/src/directtools/DirectSelection.py b/direct/src/directtools/DirectSelection.py index 12c72ca08e..68cab3ef84 100644 --- a/direct/src/directtools/DirectSelection.py +++ b/direct/src/directtools/DirectSelection.py @@ -409,7 +409,7 @@ class DirectBoundingBox: return '%.2f %.2f %.2f' % (vec[0], vec[1], vec[2]) def __repr__(self): - return (`self.__class__` + + return (repr(self.__class__) + '\nNodePath:\t%s\n' % self.nodePath.getName() + 'Min:\t\t%s\n' % self.vecAsString(self.min) + 'Max:\t\t%s\n' % self.vecAsString(self.max) + diff --git a/direct/src/distributed/AsyncRequest.py b/direct/src/distributed/AsyncRequest.py index b86b310fb6..bf76680909 100755 --- a/direct/src/distributed/AsyncRequest.py +++ b/direct/src/distributed/AsyncRequest.py @@ -243,7 +243,7 @@ class AsyncRequest(DirectObject): if self.numRetries > 0: assert AsyncRequest.notify.debug( 'Timed out. Trying %d more time(s) : %s' % - (self.numRetries + 1, `self.neededObjects`)) + (self.numRetries + 1, repr(self.neededObjects))) self.numRetries -= 1 return Task.again else: diff --git a/direct/src/distributed/DoCollectionManager.py b/direct/src/distributed/DoCollectionManager.py index 24db85d07c..f0f4f24233 100755 --- a/direct/src/distributed/DoCollectionManager.py +++ b/direct/src/distributed/DoCollectionManager.py @@ -57,7 +57,7 @@ class DoCollectionManager: Returns list of distributed objects with matching str in value. """ for value in self.doId2do.values(): - if `value`.find(str) >= 0: + if repr(value).find(str) >= 0: return value def doFindAll(self, str): @@ -66,7 +66,7 @@ class DoCollectionManager: """ matches = [] for value in self.doId2do.values(): - if `value`.find(str) >= 0: + if repr(value).find(str) >= 0: matches.append(value) return matches @@ -76,7 +76,7 @@ class DoCollectionManager: """ matches = [] for value in self.doId2do.values(): - if re.search(str,`value`): + if re.search(str,repr(value)): matches.append(value) return matches diff --git a/direct/src/extensions_native/extension_native_helpers.py b/direct/src/extensions_native/extension_native_helpers.py index c54bfae0a5..525b416876 100644 --- a/direct/src/extensions_native/extension_native_helpers.py +++ b/direct/src/extensions_native/extension_native_helpers.py @@ -59,7 +59,7 @@ if sys.platform == "win32": os.environ["PATH"] = target + ";" + path def Dtool_PreloadDLL(module): - if (sys.modules.has_key(module)): + if module in sys.modules: return # Search for the appropriate directory. diff --git a/direct/src/ffi/DoGenPyCode.py b/direct/src/ffi/DoGenPyCode.py index c83d96128c..4749475d0b 100644 --- a/direct/src/ffi/DoGenPyCode.py +++ b/direct/src/ffi/DoGenPyCode.py @@ -220,7 +220,7 @@ def doErrorCheck(): if (not codeLibs): FFIConstants.notify.error('You must specify one or more libraries to generate code from') else: - FFIConstants.notify.debug('Generating code for: ' + `codeLibs`) + FFIConstants.notify.debug('Generating code for: ' + repr(codeLibs)) FFIConstants.CodeModuleNameList = codeLibs def generateNativeWrappers(): diff --git a/direct/src/ffi/FFIExternalObject.py b/direct/src/ffi/FFIExternalObject.py index 98d68f6acf..962060715b 100644 --- a/direct/src/ffi/FFIExternalObject.py +++ b/direct/src/ffi/FFIExternalObject.py @@ -75,7 +75,7 @@ class FFIExternalObject: for base in thisClass.__bases__: res = self.getLineageInternal(base, targetBaseClass, chain+[base]) if res: - # FFIConstants.notify.debug('getLineageInternal: found path: ' + `res`) + # FFIConstants.notify.debug('getLineageInternal: found path: ' + repr(res)) return res # Not found anywhere return 0 @@ -172,7 +172,7 @@ class FFIExternalObject: downcastChain = DowncastMap.get((fromClass, toClass)) if downcastChain == None: downcastChain = self.getDowncastFunctions(toClass, fromClass) - #FFIConstants.notify.debug('downcast: computed downcast chain: ' + `downcastChain`) + #FFIConstants.notify.debug('downcast: computed downcast chain: ' + repr(downcastChain)) # Store it for next time DowncastMap[(fromClass, toClass)] = downcastChain newObject = self @@ -217,7 +217,7 @@ class FFIExternalObject: except AssertionError, e: raise AssertionError, e except: - baseRepr = ('[' + self.__class__.__name__ + ' at: ' + `self.this` + ']') + baseRepr = ('[' + self.__class__.__name__ + ' at: ' + repr(self.this) + ']') # In any case, return the baseRepr return baseRepr @@ -225,7 +225,7 @@ class FFIExternalObject: # This is a more complete version of printing which shows the object type # and pointer, plus the output from write() or output() whichever is defined # Print this info for all objects - baseRepr = ('[' + self.__class__.__name__ + ' at: ' + `self.this` + ']') + baseRepr = ('[' + self.__class__.__name__ + ' at: ' + repr(self.this) + ']') # Lots of Panda classes have an write or output function defined that takes an Ostream # We create a LineStream for the write or output function to write to, then we extract # the string out of it and return it as our repr diff --git a/direct/src/ffi/FFIInterrogateDatabase.py b/direct/src/ffi/FFIInterrogateDatabase.py index 4918b7072a..a82d852060 100644 --- a/direct/src/ffi/FFIInterrogateDatabase.py +++ b/direct/src/ffi/FFIInterrogateDatabase.py @@ -219,10 +219,10 @@ def getTypeName(typeIndex, scoped=0): else: name = name + string.capitalize(nameComponents[i][0]) + nameComponents[i][1:] - FFIConstants.notify.debug('typeIndex: ' + `typeIndex` + ' typeName: ' + typeName + ' has name: ' + name) + FFIConstants.notify.debug('typeIndex: ' + repr(typeIndex) + ' typeName: ' + typeName + ' has name: ' + name) if not name: - FFIConstants.notify.warning('typeIndex: ' + `typeIndex` + ' typeName: ' + typeName + ' has no name') + FFIConstants.notify.warning('typeIndex: ' + repr(typeIndex) + ' typeName: ' + typeName + ' has no name') name = "UnnamedType" return name @@ -262,7 +262,7 @@ class FFIInterrogateDatabase: return self.constructClassTypeDescriptor(typeIndex) else: - raise 'A type in the interrogate database was not recognized: '+ `typeIndex` + raise 'A type in the interrogate database was not recognized: '+ repr(typeIndex) def constructPrimitiveTypeDescriptor(self, typeIndex): if self.isDefinedType(typeIndex): @@ -478,7 +478,7 @@ class FFIInterrogateDatabase: name = FFIRename.nonClassNameFromCppName( interrogate_wrapper_parameter_name(functionIndex, argIndex)) else: - name = ('parameter' + `argIndex`) + name = ('parameter' + repr(argIndex)) descriptor = self.constructDescriptor( interrogate_wrapper_parameter_type(functionIndex, argIndex)) diff --git a/direct/src/ffi/FFIOverload.py b/direct/src/ffi/FFIOverload.py index a5979e72e1..5f1d2474f3 100644 --- a/direct/src/ffi/FFIOverload.py +++ b/direct/src/ffi/FFIOverload.py @@ -281,19 +281,19 @@ class FFIMethodArgumentTreeCollection: for tree in trees: # If this is the first case, output an if clause if (i == 0): - indent(file, nesting+2, 'if (numArgs == ' + `numArgs` + '):\n') + indent(file, nesting+2, 'if (numArgs == ' + repr(numArgs) + '):\n') # If this is a subsequent first case, output an elif clause else: - indent(file, nesting+2, 'elif (numArgs == ' + `numArgs` + '):\n') + indent(file, nesting+2, 'elif (numArgs == ' + repr(numArgs) + '):\n') tree.setup() tree.traverse(file, nesting+1, 0) # If the overloaded function got all the way through the if statements # it must have had the wrong number or type of arguments indent(file, nesting+2, "else:\n") - indent(file, nesting+3, "raise TypeError, 'Invalid number of arguments: ' + `numArgs` + ', expected one of: ") + indent(file, nesting+3, "raise TypeError, 'Invalid number of arguments: ' + repr(numArgs) + ', expected one of: ") for numArgs in numArgsKeys: - indent(file, 0, (`numArgs` + ' ')) + indent(file, 0, (repr(numArgs) + ' ')) indent(file, 0, "'\n") self.outputOverloadedMethodFooter(file, nesting) @@ -428,17 +428,17 @@ class FFIMethodArgumentTree: else: # Otherwise, we'll check the particular type of # the object. - condition = '(isinstance(_args[' + `level` + '], ' + typeName + '))' + condition = '(isinstance(_args[' + repr(level) + '], ' + typeName + '))' # Legal types for a float parameter include int and long. if (typeName == 'FloatType'): - condition += (' or (isinstance(_args[' + `level` + '], IntType))') - condition += (' or (isinstance(_args[' + `level` + '], LongType))') + condition += (' or (isinstance(_args[' + repr(level) + '], IntType))') + condition += (' or (isinstance(_args[' + repr(level) + '], LongType))') # Legal types for a long parameter include int. elif (typeName == 'LongType'): - condition += (' or (isinstance(_args[' + `level` + '], IntType))') + condition += (' or (isinstance(_args[' + repr(level) + '], IntType))') # Legal types for an int parameter include long. elif (typeName == 'IntType'): - condition += (' or (isinstance(_args[' + `level` + '], LongType))') + condition += (' or (isinstance(_args[' + repr(level) + '], LongType))') indent(file, nesting+2, 'if ' + condition + ':\n') @@ -452,7 +452,7 @@ class FFIMethodArgumentTree: # Output an else clause if one of the trees had arguments if oneTreeHasArgs: - indent(file, nesting+2, "raise TypeError, 'Invalid argument " + `level` + ", expected one of: ") + indent(file, nesting+2, "raise TypeError, 'Invalid argument " + repr(level) + ", expected one of: ") for name in typeNameList: indent(file, 0, ('<' + name + '> ')) indent(file, 0, "'\n") diff --git a/direct/src/ffi/FFISpecs.py b/direct/src/ffi/FFISpecs.py index 768e9d045f..9700a87a03 100644 --- a/direct/src/ffi/FFISpecs.py +++ b/direct/src/ffi/FFISpecs.py @@ -559,7 +559,7 @@ class ManifestSpecification: # with a getter if (self.intValue != None): indent(file, 0, '# Manifest: ' + self.name + '\n') - indent(file, 0, (self.name + ' = ' + `self.intValue` + '\n')) + indent(file, 0, (self.name + ' = ' + repr(self.intValue) + '\n')) indent(file, 0, '\n') elif self.definition: diff --git a/direct/src/ffi/FFITypes.py b/direct/src/ffi/FFITypes.py index c164942175..8669d2ec85 100644 --- a/direct/src/ffi/FFITypes.py +++ b/direct/src/ffi/FFITypes.py @@ -171,7 +171,7 @@ class EnumTypeDescriptor(PrimitiveTypeDescriptor): on = 1 """ for key in self.values.keys(): - indent(file, nesting, key + ' = ' + `self.values[key]` + '\n') + indent(file, nesting, key + ' = ' + repr(self.values[key]) + '\n') class DerivedTypeDescriptor(BaseTypeDescriptor): diff --git a/direct/src/gui/DirectDialog.py b/direct/src/gui/DirectDialog.py index 960a877fdf..a785b0a586 100644 --- a/direct/src/gui/DirectDialog.py +++ b/direct/src/gui/DirectDialog.py @@ -85,7 +85,7 @@ class DirectDialog(DirectFrame): # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget - ('dialogName', 'DirectDialog_' + `DirectDialog.PanelIndex`, DGG.INITOPT), + ('dialogName', 'DirectDialog_' + repr(DirectDialog.PanelIndex), DGG.INITOPT), # Default position is slightly forward in Y, so as not to # intersect the near plane, which is incorrectly set to 0 # in DX for some reason. @@ -123,7 +123,7 @@ class DirectDialog(DirectFrame): DirectFrame.__init__(self, parent) #if not self['dialogName']: - # self['dialogName'] = 'DirectDialog_' + `DirectDialog.PanelIndex` + # self['dialogName'] = 'DirectDialog_' + repr(DirectDialog.PanelIndex) # Clean up any previously existing panel with the same unique # name. We don't allow any two panels with the same name to @@ -142,7 +142,7 @@ class DirectDialog(DirectFrame): self.buttonList = [] index = 0 for i in range(self.numButtons): - name = 'Button' + `i` + name = 'Button' + repr(i) try: text = self['buttonTextList'][i] except IndexError: diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py index e71523f1f1..4603f9356c 100644 --- a/direct/src/gui/DirectFrame.py +++ b/direct/src/gui/DirectFrame.py @@ -62,7 +62,7 @@ class DirectFrame(DirectGuiWidget): textList = self['text'] # Create/destroy components for i in range(self['numStates']): - component = 'text' + `i` + component = 'text' + repr(i) # If fewer items specified than numStates, # just repeat last item try: @@ -106,7 +106,7 @@ class DirectFrame(DirectGuiWidget): # Create/destroy components for i in range(self['numStates']): - component = 'geom' + `i` + component = 'geom' + repr(i) # If fewer items specified than numStates, # just repeat last item try: @@ -154,7 +154,7 @@ class DirectFrame(DirectGuiWidget): imageList = arg # Create/destroy components for i in range(self['numStates']): - component = 'image' + `i` + component = 'image' + repr(i) # If fewer items specified than numStates, # just repeat last item try: diff --git a/direct/src/gui/DirectScrolledList.py b/direct/src/gui/DirectScrolledList.py index e138039cc6..cac7874007 100644 --- a/direct/src/gui/DirectScrolledList.py +++ b/direct/src/gui/DirectScrolledList.py @@ -385,7 +385,7 @@ class DirectScrolledList(DirectFrame): if item in self["items"]: if hasattr(self, "currentSelected") and self.currentSelected is item: del self.currentSelected - if (hasattr(item, 'destroy') and callable(item.destroy)): + if (hasattr(item, 'destroy') and hasattr(item.destroy, '__call__')): item.destroy() self["items"].remove(item) if type(item) != type(''): @@ -432,7 +432,7 @@ class DirectScrolledList(DirectFrame): item = self['items'][0] if hasattr(self, "currentSelected") and self.currentSelected is item: del self.currentSelected - if (hasattr(item, 'destroy') and callable(item.destroy)): + if (hasattr(item, 'destroy') and hasattr(item.destroy, '__call__')): item.destroy() self["items"].remove(item) if type(item) != type(''): diff --git a/direct/src/http/webAIInspector.py b/direct/src/http/webAIInspector.py index 4be110e658..38f8c1709c 100755 --- a/direct/src/http/webAIInspector.py +++ b/direct/src/http/webAIInspector.py @@ -297,7 +297,7 @@ def inspectorFor(anObject): else: print "Can't find an inspector for " + typeName inspectorName = 'Inspector' - inspector = eval(inspectorName + '(anObject)') + inspector = globals()[inspectorName](anObject) return inspector def initializeInspectorMap(): @@ -351,7 +351,7 @@ class Inspector: keys.sort() for each in keys: self._partsList.append(each) - #if not callable(eval('self.object.' + each)): + #if not hasattr(getattr(self.object, each), '__call__'): # self._partsList.append(each) def initializePartNames(self): @@ -373,7 +373,7 @@ class Inspector: def stringForPartNumber(self, partNumber): object = self.partNumber(partNumber) doc = None - if callable(object): + if hasattr(object, '__call__'): try: doc = object.__doc__ except: @@ -389,7 +389,7 @@ class Inspector: return self.object else: part = self.privatePartNumber(partNumber) - return eval('self.object.' + part) + return getattr(self.object, part) def inspectorFor(self, part): return inspectorFor(part) @@ -461,7 +461,7 @@ class DictionaryInspector(Inspector): if self.object.has_key(key): return self.object[key] else: - return eval('self.object.' + key) + return getattr(self.object, key) class SequenceInspector(Inspector): def initializePartsList(self): @@ -477,7 +477,7 @@ class SequenceInspector(Inspector): if type(index) == IntType: return self.object[index] else: - return eval('self.object.' + index) + return getattr(self.object, index) class SliceInspector(Inspector): def namedParts(self): diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index 6278a24a16..e432c7cf98 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -302,7 +302,7 @@ class PosHprScaleInterval(FunctionInterval): class Func(FunctionInterval): def __init__(self, *args, **kw): function = args[0] - assert callable(function) + assert hasattr(function, '__call__') extraArgs = args[1:] kw['extraArgs'] = extraArgs FunctionInterval.__init__(self, function, **kw) diff --git a/direct/src/interval/LerpInterval.py b/direct/src/interval/LerpInterval.py index c44b6e5435..21c31881f2 100644 --- a/direct/src/interval/LerpInterval.py +++ b/direct/src/interval/LerpInterval.py @@ -57,7 +57,7 @@ class LerpNodePathInterval(CLerpNodePathInterval): # parameter. for param in params: - if callable(param): + if hasattr(param, '__call__'): return 1 return 0 @@ -67,7 +67,7 @@ class LerpNodePathInterval(CLerpNodePathInterval): # a callable functor, calls it; otherwise, uses the param # directly. if param != None: - if callable(param): + if hasattr(param, '__call__'): func(param()) else: func(param) diff --git a/direct/src/interval/ProjectileInterval.py b/direct/src/interval/ProjectileInterval.py index f81433ba62..684c99b729 100755 --- a/direct/src/interval/ProjectileInterval.py +++ b/direct/src/interval/ProjectileInterval.py @@ -106,7 +106,7 @@ class ProjectileInterval(Interval): def doIndirections(*items): result = [] for item in items: - if callable(item): + if hasattr(item, '__call__'): item = item() result.append(item) return result @@ -214,10 +214,10 @@ class ProjectileInterval(Interval): self.endPos = self.__calcPos(self.duration) # these are the parameters that we need to know: - assert self.notify.debug('startPos: %s' % `self.startPos`) - assert self.notify.debug('endPos: %s' % `self.endPos`) + assert self.notify.debug('startPos: %s' % repr(self.startPos)) + assert self.notify.debug('endPos: %s' % repr(self.endPos)) assert self.notify.debug('duration: %s' % self.duration) - assert self.notify.debug('startVel: %s' % `self.startVel`) + assert self.notify.debug('startVel: %s' % repr(self.startVel)) assert self.notify.debug('z-accel: %s' % self.zAcc) def __initialize(self): diff --git a/direct/src/p3d/AppRunner.py b/direct/src/p3d/AppRunner.py index a5a5f7e6cd..74c8f9fc86 100644 --- a/direct/src/p3d/AppRunner.py +++ b/direct/src/p3d/AppRunner.py @@ -721,7 +721,7 @@ class AppRunner(DirectObject): __import__(moduleName) main = sys.modules[moduleName] - if hasattr(main, 'main') and callable(main.main): + if hasattr(main, 'main') and hasattr(main.main, '__call__'): main.main(self) # Now clear this flag. diff --git a/direct/src/particles/Particles.py b/direct/src/particles/Particles.py index 3d1e72be5e..4a065fe709 100644 --- a/direct/src/particles/Particles.py +++ b/direct/src/particles/Particles.py @@ -365,31 +365,31 @@ class Particles(ParticleSystem): typ = type(fun).__name__ if typ == 'ColorInterpolationFunctionConstant': c_a = fun.getColorA() - file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),'+`mod`+')\n') elif typ == 'ColorInterpolationFunctionLinear': c_a = fun.getColorA() c_b = fun.getColorB() - file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+`c_b[0]`+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ + 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),'+`mod`+')\n') elif typ == 'ColorInterpolationFunctionStepwave': c_a = fun.getColorA() c_b = fun.getColorB() w_a = fun.getWidthA() w_b = fun.getWidthB() - file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+`c_b[0]`+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - `w_a`+','+`w_b`+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ + 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ + repr(w_a)+','+`w_b`+','+`mod`+')\n') elif typ == 'ColorInterpolationFunctionSinusoid': c_a = fun.getColorA() c_b = fun.getColorB() per = fun.getPeriod() - file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+`c_b[0]`+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - `per`+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ + 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ + repr(per)+','+`mod`+')\n') elif (self.rendererType == "SparkleParticleRenderer"): file.write('# Sparkle parameters\n') @@ -468,31 +468,31 @@ class Particles(ParticleSystem): typ = type(fun).__name__ if typ == 'ColorInterpolationFunctionConstant': c_a = fun.getColorA() - file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addConstant('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),'+`mod`+')\n') elif typ == 'ColorInterpolationFunctionLinear': c_a = fun.getColorA() c_b = fun.getColorB() - file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+`c_b[0]`+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),'+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addLinear('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ + 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),'+`mod`+')\n') elif typ == 'ColorInterpolationFunctionStepwave': c_a = fun.getColorA() c_b = fun.getColorB() w_a = fun.getWidthA() w_b = fun.getWidthB() - file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+`c_b[0]`+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - `w_a`+','+`w_b`+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addStepwave('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ + 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ + repr(w_a)+','+`w_b`+','+`mod`+')\n') elif typ == 'ColorInterpolationFunctionSinusoid': c_a = fun.getColorA() c_b = fun.getColorB() per = fun.getPeriod() - file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+`t_b`+','+`t_e`+','+ \ - 'Vec4('+`c_a[0]`+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ - 'Vec4('+`c_b[0]`+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ - `per`+','+`mod`+')\n') + file.write(targ+'.renderer.getColorInterpolationManager().addSinusoid('+repr(t_b)+','+`t_e`+','+ \ + 'Vec4('+repr(c_a[0])+','+`c_a[1]`+','+`c_a[2]`+','+`c_a[3]`+'),' + \ + 'Vec4('+repr(c_b[0])+','+`c_b[1]`+','+`c_b[2]`+','+`c_b[3]`+'),' + \ + repr(per)+','+`mod`+')\n') file.write('# Emitter parameters\n') emissionType = self.emitter.getEmissionType() diff --git a/direct/src/pyinst/Builder.py b/direct/src/pyinst/Builder.py index e031f216fa..b43f18172b 100644 --- a/direct/src/pyinst/Builder.py +++ b/direct/src/pyinst/Builder.py @@ -284,10 +284,10 @@ class FullExeTarget(ArchiveTarget): def gather(self): for script in self.script: - #print "FullExeTarget.gather: script is", `script` + #print "FullExeTarget.gather: script is", repr(script) rsrc = resource.makeresource(script, self.pathprefix) rsrc = resource.scriptresource(rsrc.name, rsrc.path) - #print " resource is", `rsrc` + #print " resource is", repr(rsrc) self.toc.merge(rsrc.binaries) ArchiveTarget.gather(self) if not self.zlib: @@ -490,7 +490,7 @@ def main(opts, args): break else: #no break - couldn't find anything to build names = map(lambda x: getattr(x, 'name'), targets) - raise RuntimeError, "circular dependencies in %s" % `names` + raise RuntimeError, "circular dependencies in %s" % repr(names) targets = filter(None, targets) def run(file): diff --git a/direct/src/pyinst/carchive.py b/direct/src/pyinst/carchive.py index 1da8c6acc1..12551669e0 100644 --- a/direct/src/pyinst/carchive.py +++ b/direct/src/pyinst/carchive.py @@ -28,7 +28,7 @@ class CTOC: s[p:p+entrylen]) nmlen = slen - entrylen p = p + entrylen - (nm,) = struct.unpack(`nmlen`+'s', s[p:p+nmlen]) + (nm,) = struct.unpack(repr(nmlen)+'s', s[p:p+nmlen]) p = p + nmlen self.data.append((dpos, dlen, ulen, flag, typcd, nm[:-1])) @@ -39,7 +39,7 @@ class CTOC: rslt = [] for (dpos, dlen, ulen, flag, typcd, nm) in self.data: nmlen = len(nm) + 1 # add 1 for a '\0' - rslt.append(struct.pack(self.ENTRYSTRUCT+`nmlen`+'s', + rslt.append(struct.pack(self.ENTRYSTRUCT+repr(nmlen)+'s', nmlen+entrylen, dpos, dlen, ulen, flag, typcd, nm+'\0')) return string.join(rslt, '') diff --git a/direct/src/pyinst/carchive_rt.py b/direct/src/pyinst/carchive_rt.py index c58d83eb18..409c5254de 100644 --- a/direct/src/pyinst/carchive_rt.py +++ b/direct/src/pyinst/carchive_rt.py @@ -27,7 +27,7 @@ class CTOC: s[p:p+entrylen]) nmlen = slen - entrylen p = p + entrylen - (nm,) = struct.unpack(`nmlen`+'s', s[p:p+nmlen]) + (nm,) = struct.unpack(repr(nmlen)+'s', s[p:p+nmlen]) p = p + nmlen self.data.append((dpos, dlen, ulen, flag, typcd, nm[:-1])) @@ -37,7 +37,7 @@ class CTOC: ## rslt = [] ## for (dpos, dlen, ulen, flag, typcd, nm) in self.data: ## nmlen = len(nm) + 1 # add 1 for a '\0' -## rslt.append(struct.pack(self.ENTRYSTRUCT+`nmlen`+'s', +## rslt.append(struct.pack(self.ENTRYSTRUCT+repr(nmlen)+'s', ## nmlen+entrylen, dpos, dlen, ulen, flag, typcd, nm+'\0')) ## return string.join(rslt, '') ## diff --git a/direct/src/pyinst/ltoc.py b/direct/src/pyinst/ltoc.py index da51d50340..86a741f805 100644 --- a/direct/src/pyinst/ltoc.py +++ b/direct/src/pyinst/ltoc.py @@ -56,7 +56,7 @@ class lTOC(UserList.UserList): raise ValueError, "can't make filter from %s", repr(filter) else: raise ValueError, "can't make filter from %s", repr(filter) - print " added filter", `self.filters[-1]` + print " added filter", repr(self.filters[-1]) if __name__ == '__main__': diff --git a/direct/src/pyinst/modulefinder.py b/direct/src/pyinst/modulefinder.py index c2857876c3..87773602d7 100644 --- a/direct/src/pyinst/modulefinder.py +++ b/direct/src/pyinst/modulefinder.py @@ -45,11 +45,11 @@ class Module: self.__code__ = None def __repr__(self): - s = "Module(%s" % `self.__name__` + s = "Module(%s" % repr(self.__name__) if self.__file__ is not None: - s = s + ", %s" % `self.__file__` + s = s + ", %s" % repr(self.__file__) if self.__path__ is not None: - s = s + ", %s" % `self.__path__` + s = s + ", %s" % repr(self.__path__) s = s + ")" return s @@ -410,7 +410,7 @@ def test(): if debug > 1: print "path:" for item in path: - print " ", `item` + print " ", repr(item) # Create the module finder and turn its crank mf = ModuleFinder(path, debug, exclude) diff --git a/direct/src/pyinst/resource.py b/direct/src/pyinst/resource.py index e4927e783c..07c0f2f700 100644 --- a/direct/src/pyinst/resource.py +++ b/direct/src/pyinst/resource.py @@ -243,7 +243,7 @@ class dirresource(resource): self._contents.append(rsrc) except ValueError, e: raise RuntimeError, "Can't make resource from %s\n ValueError: %s" \ - % (os.path.join(self.path, fnm), `e.args`) + % (os.path.join(self.path, fnm), repr(e.args)) return self._contents def asFilter(self): return tocfilter.DirFilter([self.path]) diff --git a/direct/src/showbase/BufferViewer.py b/direct/src/showbase/BufferViewer.py index aec7ea44da..cf2d4a55ad 100644 --- a/direct/src/showbase/BufferViewer.py +++ b/direct/src/showbase/BufferViewer.py @@ -282,7 +282,7 @@ class BufferViewer(DirectObject): win = base.graphicsEngine.getWindow(iwin) for itex in range(win.countTextures()): tex = win.getTexture(itex) - if (include.has_key(tex)) and (exclude.has_key(tex)==0): + if (tex in include) and (tex not in exclude): if (tex.getTextureType() == Texture.TTCubeMap): for face in range(6): self.cardmaker.setUvRangeCube(face) @@ -347,9 +347,9 @@ class BufferViewer(DirectObject): if (float(self.sizex)==0.0) and (float(self.sizey)==0.0): sizey = int(0.4266666667 * base.win.getYSize()) - sizex = (sizey * aspectx) / aspecty - v_sizey = (base.win.getYSize() - (rows-1) - (rows*2)) / rows - v_sizex = (v_sizey * aspectx) / aspecty + sizex = (sizey * aspectx) // aspecty + v_sizey = (base.win.getYSize() - (rows-1) - (rows*2)) // rows + v_sizex = (v_sizey * aspectx) // aspecty if (v_sizey < sizey) or (v_sizex < sizex): sizey = v_sizey sizex = v_sizex @@ -361,15 +361,15 @@ class BufferViewer(DirectObject): if (h_sizex < 1.0): h_sizex = 1.0 - h_sizey = (h_sizex * aspecty) / aspectx + h_sizey = (h_sizex * aspecty) // aspectx if (h_sizey < sizey) or (h_sizex < sizex): sizey = h_sizey sizex = h_sizex else: sizex = int(self.sizex * 0.5 * base.win.getXSize()) sizey = int(self.sizey * 0.5 * base.win.getYSize()) - if (sizex == 0): sizex = (sizey*aspectx) / aspecty - if (sizey == 0): sizey = (sizex*aspecty) / aspectx + if (sizex == 0): sizex = (sizey*aspectx) // aspecty + if (sizey == 0): sizey = (sizex*aspecty) // aspectx # Convert from pixels to render2d-units. fsizex = (2.0 * sizex) / float(base.win.getXSize()) diff --git a/direct/src/showbase/DistancePhasedNode.py b/direct/src/showbase/DistancePhasedNode.py index 967755ea7a..3f8be4306d 100755 --- a/direct/src/showbase/DistancePhasedNode.py +++ b/direct/src/showbase/DistancePhasedNode.py @@ -106,10 +106,10 @@ class DistancePhasedNode(PhasedObject, DirectObject, NodePath): def __repr__(self): outStr = 'DistancePhasedObject(' - outStr += '%s' % `self.getName()` + outStr += '%s' % repr(self.getName()) for param, value in zip(('phaseParamMap', 'autoCleanup', 'enterPrefix', 'exitPrefix', 'phaseCollideMask', 'fromCollideNode'), ('{}', 'True','\'enter\'','\'exit\'','BitMask32.allOn()','None')): - outStr += eval('(\', ' + param + ' = %s\' % `self.' + param + '`,\'\')[self.' + param + ' == ' + value + ']') + outStr += eval('(\', ' + param + ' = %s\' % repr(self.' + param + '),\'\')[self.' + param + ' == ' + value + ']') outStr += ')' return outStr @@ -287,10 +287,10 @@ class BufferedDistancePhasedNode(DistancePhasedNode): def __repr__(self): outStr = 'BufferedDistancePhasedNode(' - outStr += '%s' % `self.getName()` + outStr += '%s' % repr(self.getName()) for param, value in zip(('bufferParamMap', 'autoCleanup', 'enterPrefix', 'exitPrefix', 'phaseCollideMask', 'fromCollideNode'), ('{}', 'True','\'enter\'','\'exit\'','BitMask32.allOn()', 'None')): - outStr += eval('(\', ' + param + ' = %s\' % `self.' + param + '`,\'\')[self.' + param + ' == ' + value + ']') + outStr += eval('(\', ' + param + ' = %s\' % repr(self.' + param + '),\'\')[self.' + param + ' == ' + value + ']') outStr += ')' return outStr diff --git a/direct/src/showbase/EventManager.py b/direct/src/showbase/EventManager.py index 1e09409f5c..62a21ba41a 100644 --- a/direct/src/showbase/EventManager.py +++ b/direct/src/showbase/EventManager.py @@ -112,7 +112,7 @@ class EventManager: # Do not print the new frame debug, it is too noisy! if (EventManager.notify.getDebug() and eventName != 'NewFrame'): EventManager.notify.debug('received C++ event named: ' + eventName + - ' parameters: ' + `paramList`) + ' parameters: ' + repr(paramList)) # ************************************************************** # ******** Duplicate any changes in processEventPstats ********* # ************************************************************** @@ -149,7 +149,7 @@ class EventManager: # Do not print the new frame debug, it is too noisy! if (EventManager.notify.getDebug() and eventName != 'NewFrame'): EventManager.notify.debug('received C++ event named: ' + eventName + - ' parameters: ' + `paramList`) + ' parameters: ' + repr(paramList)) # Send the event, we used to send it with the event # name as a parameter, but now you can use extraArgs for that # ******************************************************** diff --git a/direct/src/showbase/Messenger.py b/direct/src/showbase/Messenger.py index 19748a9ee9..f62dfa021d 100644 --- a/direct/src/showbase/Messenger.py +++ b/direct/src/showbase/Messenger.py @@ -125,7 +125,7 @@ class Messenger: safeRepr(extraArgs), persistent)) # Make sure that the method is callable - assert callable(method), ( + assert hasattr(method, '__call__'), ( "method not callable in accept (ignoring): %s %s"% (safeRepr(method), safeRepr(extraArgs))) @@ -141,7 +141,7 @@ class Messenger: # Make sure we are not inadvertently overwriting an existing event # on this particular object. - if acceptorDict.has_key(id): + if id in acceptorDict: # TODO: we're replacing the existing callback. should this be an error? if notifyDebug: oldMethod = acceptorDict[id][0] @@ -180,7 +180,7 @@ class Messenger: # Find the dictionary of all the objects accepting this event acceptorDict = self.__callbacks.get(event) # If this object is there, delete it from the dictionary - if acceptorDict and acceptorDict.has_key(id): + if acceptorDict and id in acceptorDict: del acceptorDict[id] # If this dictionary is now empty, remove the event # entry from the Messenger alltogether @@ -189,7 +189,7 @@ class Messenger: # This object is no longer listening for this event eventDict = self.__objectEvents.get(id) - if eventDict and eventDict.has_key(event): + if eventDict and event in eventDict: del eventDict[event] if (len(eventDict) == 0): del self.__objectEvents[id] @@ -217,7 +217,7 @@ class Messenger: # Find the dictionary of all the objects accepting this event acceptorDict = self.__callbacks.get(event) # If this object is there, delete it from the dictionary - if acceptorDict and acceptorDict.has_key(id): + if acceptorDict and id in acceptorDict: del acceptorDict[id] # If this dictionary is now empty, remove the event # entry from the Messenger alltogether @@ -252,7 +252,7 @@ class Messenger: try: acceptorDict = self.__callbacks.get(event) id = self._getMessengerId(object) - if acceptorDict and acceptorDict.has_key(id): + if acceptorDict and id in acceptorDict: # Found it, return true return 1 # If we looked in both dictionaries and made it here @@ -373,7 +373,7 @@ class Messenger: if not persistent: # This object is no longer listening for this event eventDict = self.__objectEvents.get(id) - if eventDict and eventDict.has_key(event): + if eventDict and event in eventDict: del eventDict[event] if (len(eventDict) == 0): del self.__objectEvents[id] @@ -382,7 +382,7 @@ class Messenger: del acceptorDict[id] # If the dictionary at this event is now empty, remove # the event entry from the Messenger altogether - if (self.__callbacks.has_key(event) \ + if (event in self.__callbacks \ and (len(self.__callbacks[event]) == 0)): del self.__callbacks[event] @@ -402,7 +402,7 @@ class Messenger: # we have cleaned up the accept hook, because the # method itself might call accept() or acceptOnce() # again. - assert callable(method) + assert hasattr(method, '__call__') # Release the lock temporarily while we call the method. self.lock.release() @@ -445,10 +445,10 @@ class Messenger: function = method.im_func else: function = method - #print ('function: ' + `function` + '\n' + - # 'method: ' + `method` + '\n' + - # 'oldMethod: ' + `oldMethod` + '\n' + - # 'newFunction: ' + `newFunction` + '\n') + #print ('function: ' + repr(function) + '\n' + + # 'method: ' + repr(method) + '\n' + + # 'oldMethod: ' + repr(oldMethod) + '\n' + + # 'newFunction: ' + repr(newFunction) + '\n') if (function == oldMethod): newMethod = new.instancemethod( newFunction, method.im_self, method.im_class) @@ -530,7 +530,7 @@ class Messenger: keys = self.__callbacks.keys() keys.sort() for event in keys: - if `event`.find(needle) >= 0: + if repr(event).find(needle) >= 0: print self.__eventRepr(event), return {event: self.__callbacks[event]} @@ -544,7 +544,7 @@ class Messenger: keys = self.__callbacks.keys() keys.sort() for event in keys: - if `event`.find(needle) >= 0: + if repr(event).find(needle) >= 0: print self.__eventRepr(event), matches[event] = self.__callbacks[event] # if the limit is not None, decrement and @@ -620,16 +620,16 @@ class Messenger: str = (str + '\t' + 'Acceptor: ' + className + ' instance' + '\n\t' + 'Function name:' + functionName + '\n\t' + - 'Extra Args: ' + `extraArgs` + '\n\t' + - 'Persistent: ' + `persistent` + '\n') + 'Extra Args: ' + repr(extraArgs) + '\n\t' + + 'Persistent: ' + repr(persistent) + '\n') # If this is a class method, get its actual function if (type(function) == types.MethodType): str = (str + '\t' + - 'Method: ' + `function` + '\n\t' + - 'Function: ' + `function.im_func` + '\n') + 'Method: ' + repr(function) + '\n\t' + + 'Function: ' + repr(function.im_func) + '\n') else: str = (str + '\t' + - 'Function: ' + `function` + '\n') + 'Function: ' + repr(function) + '\n') str = str + '='*50 + '\n' return str diff --git a/direct/src/showbase/ProfileSession.py b/direct/src/showbase/ProfileSession.py index 4ee0a70ea2..ad2cdc2606 100755 --- a/direct/src/showbase/ProfileSession.py +++ b/direct/src/showbase/ProfileSession.py @@ -165,7 +165,7 @@ class ProfileSession: self._duration = 0. else: # put the function in the global namespace so that profile can find it - assert callable(self._func) + assert hasattr(self._func, '__call__') __builtin__.globalProfileSessionFunc = self._func __builtin__.globalProfileSessionResult = [None] diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index d72b6d66a1..1a8814ffd0 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -92,7 +92,7 @@ def Functor(function, *args, **kArgs): class Functor: def __init__(self, function, *args, **kargs): - assert callable(function), "function should be a callable obj" + assert hasattr(function, '__call__'), "function should be a callable obj" self._function = function self._args = args self._kargs = kargs @@ -316,7 +316,7 @@ def traceFunctionCall(frame): if co.co_flags & 4: n = n+1 if co.co_flags & 8: n = n+1 r='' - if dict.has_key('self'): + if 'self' in dict: r = '%s.'%(dict['self'].__class__.__name__,) r+="%s("%(f.f_code.co_name,) comma=0 # formatting, whether we should type a comma. @@ -331,7 +331,7 @@ def traceFunctionCall(frame): comma=1 r+=name r+='=' - if dict.has_key(name): + if name in dict: v=str(dict[name]) if len(v)>2000: # r+="" @@ -507,13 +507,13 @@ def _pdir(obj, str = None, width = None, keys = aproposKeys + privateKeys + remainingKeys else: keys = aproposKeys + remainingKeys - format = '%-' + `maxWidth` + 's' + format = '%-' + repr(maxWidth) + 's' for key in keys: value = dict[key] - if callable(value): - strvalue = `Signature(value)` + if hasattr(value, '__call__'): + strvalue = repr(Signature(value)) else: - strvalue = `value` + strvalue = repr(value) if fTruncate: # Cut off line (keeping at least 1 char) strvalue = strvalue[:max(1, lineWidth - maxWidth)] @@ -569,7 +569,7 @@ def _getcode(f): try: return codedict[type(f)](f) except KeyError: - if callable(f): # eg, built-in functions and methods + if hasattr(f, '__call__'): # eg, built-in functions and methods # raise ValueError, "type %s not supported yet." % type(f) return f.__name__, None else: @@ -599,9 +599,9 @@ class Signature: def full_arglist(self): base = list(self.ordinary_args()) x = self.special_args() - if x.has_key('positional'): + if 'positional' in x: base.append(x['positional']) - if x.has_key('keyword'): + if 'keyword' in x: base.append(x['keyword']) return base def defaults(self): @@ -620,13 +620,13 @@ class Signature: specials = self.special_args() l = [] for arg in self.ordinary_args(): - if defaults.has_key(arg): + if arg in defaults: l.append(arg + '=' + str(defaults[arg])) else: l.append(arg) - if specials.has_key('positional'): + if 'positional' in specials: l.append('*' + specials['positional']) - if specials.has_key('keyword'): + if 'keyword' in specials: l.append('**' + specials['keyword']) return "%s(%s)" % (self.name, string.join(l, ', ')) else: @@ -1432,12 +1432,12 @@ class ParamObj: def getDefaultValue(cls, param): cls._compileDefaultParams() dv = cls._Params[param] - if callable(dv): + if hasattr(dv, '__call__'): dv = dv() return dv @classmethod def _compileDefaultParams(cls): - if cls.__dict__.has_key('_Params'): + if '_Params' in cls.__dict__: # we've already compiled the defaults for this class return bases = list(cls.__bases__) @@ -1447,7 +1447,7 @@ class ParamObj: for c in (bases + [cls]): # make sure this base has its dict of param defaults c._compileDefaultParams() - if c.__dict__.has_key('Params'): + if 'Params' in c.__dict__: # apply this class' default param values to our dict cls._Params.update(c.Params) def __repr__(self): @@ -1778,16 +1778,16 @@ class POD: # as the default value itself; we need a way to specify that the # callable *is* the default value and not a default-value creation # function - if callable(dv): + if hasattr(dv, '__call__'): dv = dv() return dv @classmethod def _compileDefaultDataSet(cls): - if cls.__dict__.has_key('_DataSet'): + if '_DataSet' in cls.__dict__: # we've already compiled the defaults for this class return # create setters & getters for this class - if cls.__dict__.has_key('DataSet'): + if 'DataSet' in cls.__dict__: for name in cls.DataSet: setterName = getSetterName(name) if not hasattr(cls, setterName): @@ -2454,7 +2454,7 @@ def printListEnumGen(l): n = len(l) while n > 0: digits += 1 - n /= 10 + n //= 10 format = '%0' + '%s' % digits + 'i:%s' for i in range(len(l)): print format % (i, l[i]) @@ -2796,7 +2796,7 @@ def getNumberedTypedString(items, maxLen=5000, numPrefix=''): n = len(items) while n > 0: digits += 1 - n /= 10 + n //= 10 digits = digits format = numPrefix + '%0' + '%s' % digits + 'i:%s \t%s' first = True @@ -2820,7 +2820,7 @@ def getNumberedTypedSortedString(items, maxLen=5000, numPrefix=''): n = len(items) while n > 0: digits += 1 - n /= 10 + n //= 10 digits = digits format = numPrefix + '%0' + '%s' % digits + 'i:%s \t%s' snip = '' @@ -2849,7 +2849,7 @@ def getNumberedTypedSortedStringWithReferrersGen(items, maxLen=10000, numPrefix= n = len(items) while n > 0: digits += 1 - n /= 10 + n //= 10 digits = digits format = numPrefix + '%0' + '%s' % digits + 'i:%s @ %s \t%s' snip = '' @@ -2885,7 +2885,7 @@ def printNumberedTyped(items, maxLen=5000): n = len(items) while n > 0: digits += 1 - n /= 10 + n //= 10 digits = digits format = '%0' + '%s' % digits + 'i:%s \t%s' for i in xrange(len(items)): @@ -2900,7 +2900,7 @@ def printNumberedTypesGen(items, maxLen=5000): n = len(items) while n > 0: digits += 1 - n /= 10 + n //= 10 digits = digits format = '%0' + '%s' % digits + 'i:%s' for i in xrange(len(items)): @@ -3283,8 +3283,8 @@ def report(types = [], prefix = '', xform = None, notifyFunc = None, dConfigPara rArgs = [] if 'args' in types: - rArgs += [`x`+', ' for x in args[1:]] + \ - [ x + ' = ' + '%s, ' % `y` for x,y in kwargs.items()] + rArgs += [repr(x)+', ' for x in args[1:]] + \ + [ x + ' = ' + '%s, ' % repr(y) for x,y in kwargs.items()] if not rArgs: rArgs = '()' @@ -3469,7 +3469,7 @@ def logMethodCalls(cls): raise 'logMethodCalls: class \'%s\' must have a notify' % cls.__name__ for name in dir(cls): method = getattr(cls, name) - if callable(method): + if hasattr(method, '__call__'): def getLoggedMethodCall(method): def __logMethodCall__(obj, *args, **kArgs): s = '%s(' % method.__name__ @@ -3710,8 +3710,8 @@ class MiniLog: ('*'*50, self.name, '-'*50, '\n'.join(self.lines), '*'*50) def enterFunction(self, funcName, *args, **kw): - rArgs = [`x`+', ' for x in args] + \ - [ x + ' = ' + '%s, ' % `y` for x,y in kw.items()] + rArgs = [repr(x)+', ' for x in args] + \ + [ x + ' = ' + '%s, ' % repr(y) for x,y in kw.items()] if not rArgs: rArgs = '()' @@ -3786,13 +3786,13 @@ def formatTimeCompact(seconds): result = '' a = int(seconds) seconds = a % 60 - a /= 60 + a //= 60 if a > 0: minutes = a % 60 - a /= 60 + a //= 60 if a > 0: hours = a % 24 - a /= 24 + a //= 24 if a > 0: days = a result += '%sd' % days @@ -3819,13 +3819,13 @@ def formatTimeExact(seconds): result = '' a = int(seconds) seconds = a % 60 - a /= 60 + a //= 60 if a > 0: minutes = a % 60 - a /= 60 + a //= 60 if a > 0: hours = a % 24 - a /= 24 + a //= 24 if a > 0: days = a result += '%sd' % days @@ -3963,16 +3963,16 @@ def startSuperLog(customFunction = None): def trace_dispatch(a,b,c): if(b=='call' and a.f_code.co_name != '?' and a.f_code.co_name.find("safeRepr")<0): vars = dict(a.f_locals) - if(vars.has_key('self')): + if 'self' in vars: del vars['self'] - if(vars.has_key('__builtins__')): + if '__builtins__' in vars: del vars['__builtins__'] for i in vars: vars[i] = safeReprTypeOnFail(vars[i]) - if(customFunction): + if customFunction: superLogFile.write( "before = %s"%customFunction()) superLogFile.write( "%s(%s):%s:%s\n"%(a.f_code.co_filename.split("\\")[-1],a.f_code.co_firstlineno, a.f_code.co_name, vars)) - if(customFunction): + if customFunction: superLogFile.write( "after = %s"%customFunction()) return trace_dispatch sys.settrace(trace_dispatch) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index dda8320835..b6453ddeaa 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -2359,7 +2359,7 @@ class ShowBase(DirectObject.DirectObject): t.frameIndex = 0 # Frame 0 is not captured. t.numFrames = int(duration * fps) t.source = source - t.outputString = namePrefix + '_%0' + `sd` + 'd.' + format + t.outputString = namePrefix + '_%0' + repr(sd) + 'd.' + format t.setUponDeath(lambda state: globalClock.setMode(ClockObject.MNormal)) def _movieTask(self, state): diff --git a/direct/src/stdpy/glob.py b/direct/src/stdpy/glob.py index 9ff4ec237b..3d1cce60f4 100755 --- a/direct/src/stdpy/glob.py +++ b/direct/src/stdpy/glob.py @@ -47,7 +47,7 @@ def iglob(pathname): yield os.path.join(dirname, name) # These 2 helper functions non-recursively glob inside a literal directory. -# They return a list of basenames. `glob1` accepts a pattern while `glob0` +# They return a list of basenames. repr(glob1) accepts a pattern while `glob0` # takes a literal basename (so it only has to check for its existence). def glob1(dirname, pattern): @@ -66,7 +66,7 @@ def glob1(dirname, pattern): def glob0(dirname, basename): if basename == '': - # `os.path.split()` returns an empty basename for paths ending with a + # repr(os.path.split()) returns an empty basename for paths ending with a # directory separator. 'q*x/' should match only directories. if file.isdir(dirname): return [basename] diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index c190f96523..84df84f5cb 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -370,7 +370,7 @@ class TaskManager: def __setupTask(self, funcOrTask, name, priority, sort, extraArgs, taskChain, appendTask, owner, uponDeath): if isinstance(funcOrTask, AsyncTask): task = funcOrTask - elif callable(funcOrTask): + elif hasattr(funcOrTask, '__call__'): task = PythonTask(funcOrTask) else: self.notify.error( diff --git a/direct/src/tkpanels/DirectSessionPanel.py b/direct/src/tkpanels/DirectSessionPanel.py index 50cdf0330b..0cbd509a1c 100644 --- a/direct/src/tkpanels/DirectSessionPanel.py +++ b/direct/src/tkpanels/DirectSessionPanel.py @@ -216,7 +216,7 @@ class DirectSessionPanel(AppShell): Label(drFrame, text = 'Display Region', font=('MSSansSerif', 14, 'bold')).pack(expand = 0) - nameList = map(lambda x: 'Display Region ' + `x`, + nameList = map(lambda x: 'Display Region ' + repr(x), range(len(base.direct.drList))) self.drMenu = Pmw.ComboBox( drFrame, labelpos = W, label_text = 'Display Region:', @@ -725,7 +725,7 @@ class DirectSessionPanel(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + `nodePath.id()` + dictName = name + '-' + repr(nodePath.id()) if not dict.has_key(dictName): # Update combo box to include new item names.append(dictName) diff --git a/direct/src/tkpanels/FSMInspector.py b/direct/src/tkpanels/FSMInspector.py index b018748ac7..3ec7cafaaa 100644 --- a/direct/src/tkpanels/FSMInspector.py +++ b/direct/src/tkpanels/FSMInspector.py @@ -71,7 +71,7 @@ class FSMInspector(AppShell): 'Set state label size', tearoff = 1) for size in (8, 10, 12, 14, 18, 24): menuBar.addmenuitem('Font Size', 'command', - 'Set font to: ' + `size` + ' Pts', label = `size` + ' Pts', + 'Set font to: ' + repr(size) + ' Pts', label = `size` + ' Pts', command = lambda s = self, sz = size: s.setFontSize(sz)) menuBar.addcascademenu('States', 'Marker Size', 'Set state marker size', tearoff = 1) diff --git a/direct/src/tkpanels/Inspector.py b/direct/src/tkpanels/Inspector.py index 69c277acaf..0989a5b7e9 100644 --- a/direct/src/tkpanels/Inspector.py +++ b/direct/src/tkpanels/Inspector.py @@ -29,7 +29,7 @@ def inspectorFor(anObject): else: print "Can't find an inspector for " + typeName inspectorName = 'Inspector' - inspector = eval(inspectorName + '(anObject)') + inspector = globals()[inspectorName](anObject) return inspector @@ -88,7 +88,7 @@ class Inspector: keys.sort() for each in keys: self._partsList.append(each) - #if not callable(eval('self.object.' + each)): + #if not hasattr(getattr(self.object, each), '__call__'): # self._partsList.append(each) def initializePartNames(self): @@ -110,7 +110,7 @@ class Inspector: def stringForPartNumber(self, partNumber): object = self.partNumber(partNumber) doc = None - if callable(object): + if hasattr(object, '__call__'): try: doc = object.__doc__ except: @@ -126,7 +126,7 @@ class Inspector: return self.object else: part = self.privatePartNumber(partNumber) - return eval('self.object.' + part) + return getattr(self.object, part) def inspectorFor(self, part): return inspectorFor(part) @@ -198,7 +198,7 @@ class DictionaryInspector(Inspector): if self.object.has_key(key): return self.object[key] else: - return eval('self.object.' + key) + return getattr(self.object, key) class SequenceInspector(Inspector): def initializePartsList(self): @@ -214,7 +214,7 @@ class SequenceInspector(Inspector): if type(index) == IntType: return self.object[index] else: - return eval('self.object.' + index) + return getattr(self.object, index) class SliceInspector(Inspector): def namedParts(self): @@ -341,7 +341,7 @@ class InspectorWindow: partDict = { 'this': self.selectedPart(), 'object': self.topInspector().object } result = eval(command, partDict) - self.commandWidget.insert(INSERT, `result` + '\n>>> ') + self.commandWidget.insert(INSERT, repr(result) + '\n>>> ') self.commandWidget.see(INSERT) # Menu Events diff --git a/direct/src/tkpanels/MopathRecorder.py b/direct/src/tkpanels/MopathRecorder.py index 821b720850..71f9dbd12e 100644 --- a/direct/src/tkpanels/MopathRecorder.py +++ b/direct/src/tkpanels/MopathRecorder.py @@ -111,7 +111,7 @@ class MopathRecorder(AppShell, DirectObject): self.postPoints = [] self.pointSetDict = {} self.pointSetCount = 0 - self.pointSetName = self.name + '-ps-' + `self.pointSetCount` + self.pointSetName = self.name + '-ps-' + repr(self.pointSetCount) # User callback to call before recording point self.samplingMode = 'Continuous' self.preRecordFunc = None @@ -774,7 +774,7 @@ class MopathRecorder(AppShell, DirectObject): taskMgr.remove(self.name + '-curveEditTask') def createNewPointSet(self): - self.pointSetName = self.name + '-ps-' + `self.pointSetCount` + self.pointSetName = self.name + '-ps-' + repr(self.pointSetCount) # Update dictionary and record pointer to new point set self.pointSet = self.pointSetDict[self.pointSetName] = [] # Update combo box @@ -1247,7 +1247,7 @@ class MopathRecorder(AppShell, DirectObject): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + `nodePath.id()` + dictName = name + '-' + repr(nodePath.id()) if not dict.has_key(dictName): # Update combo box to include new item names.append(dictName) @@ -1616,7 +1616,7 @@ class MopathRecorder(AppShell, DirectObject): # Use first directory in model path mPath = getModelPath() if mPath.getNumDirectories() > 0: - if `mPath.getDirectory(0)` == '.': + if repr(mPath.getDirectory(0)) == '.': path = '.' else: path = mPath.getDirectory(0).toOsSpecific() @@ -1655,7 +1655,7 @@ class MopathRecorder(AppShell, DirectObject): # Use first directory in model path mPath = getModelPath() if mPath.getNumDirectories() > 0: - if `mPath.getDirectory(0)` == '.': + if repr(mPath.getDirectory(0)) == '.': path = '.' else: path = mPath.getDirectory(0).toOsSpecific() diff --git a/direct/src/tkpanels/ParticlePanel.py b/direct/src/tkpanels/ParticlePanel.py index 971e25b4af..74dfe97b3d 100644 --- a/direct/src/tkpanels/ParticlePanel.py +++ b/direct/src/tkpanels/ParticlePanel.py @@ -1239,7 +1239,7 @@ class ParticlePanel(AppShell): # Find path to particle directory pPath = getParticlePath() if pPath.getNumDirectories() > 0: - if `pPath.getDirectory(0)` == '.': + if repr(pPath.getDirectory(0)) == '.': path = '.' else: path = pPath.getDirectory(0).toOsSpecific() @@ -1267,7 +1267,7 @@ class ParticlePanel(AppShell): # Find path to particle directory pPath = getParticlePath() if pPath.getNumDirectories() > 0: - if `pPath.getDirectory(0)` == '.': + if repr(pPath.getDirectory(0)) == '.': path = '.' else: path = pPath.getDirectory(0).toOsSpecific() @@ -1900,7 +1900,7 @@ class ParticlePanel(AppShell): frameNum = len([x for x in self.rendererSpriteAnimationWidgetList if x]) self.rendererSpriteAnimationWidgetList.append( - self.createSpriteAnimationTextureWidget(parent, anim, `frameNum`)) + self.createSpriteAnimationTextureWidget(parent, anim, repr(frameNum))) else: animId = len([x for x in self.rendererSpriteAnimationWidgetList if x and x.valid]) anim = SpriteAnim.STTexture @@ -1908,7 +1908,7 @@ class ParticlePanel(AppShell): frameNum = len([x for x in self.rendererSpriteAnimationWidgetList if x]) self.rendererSpriteAnimationWidgetList.append( - self.createSpriteAnimationTextureWidget(parent, anim, `frameNum`)) + self.createSpriteAnimationTextureWidget(parent, anim, repr(frameNum))) parent.pack(fill=BOTH, expand=1) def addRendererSpriteAnimationFromNode(self): ren = self.particles.getRenderer() @@ -1921,7 +1921,7 @@ class ParticlePanel(AppShell): frameNum = len([x for x in self.rendererSpriteAnimationWidgetList if x]) self.rendererSpriteAnimationWidgetList.append( - self.createSpriteAnimationNodeWidget(parent, anim, `frameNum`)) + self.createSpriteAnimationNodeWidget(parent, anim, repr(frameNum))) else: animId = len([x for x in self.rendererSpriteAnimationWidgetList if x and x.valid]) anim = SpriteAnim.STFromNode @@ -1929,7 +1929,7 @@ class ParticlePanel(AppShell): frameNum = len([x for x in self.rendererSpriteAnimationWidgetList if x]) self.rendererSpriteAnimationWidgetList.append( - self.createSpriteAnimationNodeWidget(parent, anim, `frameNum`)) + self.createSpriteAnimationNodeWidget(parent, anim, repr(frameNum))) parent.pack(fill=BOTH, expand=1) def toggleRendererSpriteXScale(self): @@ -2055,12 +2055,12 @@ class ParticlePanel(AppShell): if(ren.__class__.__name__ == 'SpriteParticleRendererExt'): parent = self.rendererSpriteSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Constant' + segName = repr(len(self.rendererSegmentWidgetList))+':Constant' self.rendererSegmentWidgetList.append( self.createConstantInterpolationSegmentWidget(parent, segName, seg)) elif(ren.__class__.__name__ == 'GeomParticleRenderer'): parent = self.rendererGeomSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Constant' + segName = repr(len(self.rendererSegmentWidgetList))+':Constant' self.rendererSegmentWidgetList.append( self.createConstantInterpolationSegmentWidget(parent, segName, seg)) parent.pack(fill=BOTH, expand=1) @@ -2075,12 +2075,12 @@ class ParticlePanel(AppShell): if(ren.__class__.__name__ == 'SpriteParticleRendererExt'): parent = self.rendererSpriteSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Linear' + segName = repr(len(self.rendererSegmentWidgetList))+':Linear' self.rendererSegmentWidgetList.append( self.createLinearInterpolationSegmentWidget(parent, segName, seg)) elif(ren.__class__.__name__ == 'GeomParticleRenderer'): parent = self.rendererGeomSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Linear' + segName = repr(len(self.rendererSegmentWidgetList))+':Linear' self.rendererSegmentWidgetList.append( self.createLinearInterpolationSegmentWidget(parent, segName, seg)) parent.pack(fill=BOTH, expand=1) @@ -2095,12 +2095,12 @@ class ParticlePanel(AppShell): if(ren.__class__.__name__ == 'SpriteParticleRendererExt'): parent = self.rendererSpriteSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Stepwave' + segName = repr(len(self.rendererSegmentWidgetList))+':Stepwave' self.rendererSegmentWidgetList.append( self.createStepwaveInterpolationSegmentWidget(parent, segName, seg)) elif(ren.__class__.__name__ == 'GeomParticleRenderer'): parent = self.rendererGeomSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Stepwave' + segName = repr(len(self.rendererSegmentWidgetList))+':Stepwave' self.rendererSegmentWidgetList.append( self.createStepwaveInterpolationSegmentWidget(parent, segName, seg)) parent.pack(fill=BOTH, expand=1) @@ -2115,12 +2115,12 @@ class ParticlePanel(AppShell): if(ren.__class__.__name__ == 'SpriteParticleRendererExt'): parent = self.rendererSpriteSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Sinusoid' + segName = repr(len(self.rendererSegmentWidgetList))+':Sinusoid' self.rendererSegmentWidgetList.append( self.createSinusoidInterpolationSegmentWidget(parent, segName, seg)) elif(ren.__class__.__name__ == 'GeomParticleRenderer'): parent = self.rendererGeomSegmentFrame - segName = `len(self.rendererSegmentWidgetList)`+':Sinusoid' + segName = repr(len(self.rendererSegmentWidgetList))+':Sinusoid' self.rendererSegmentWidgetList.append( self.createSinusoidInterpolationSegmentWidget(parent, segName, seg)) parent.pack(fill=BOTH, expand=1) @@ -2375,7 +2375,7 @@ class ParticlePanel(AppShell): if frame.valid: strVar.set(anim.getTexSource()) else: - strVar.set('Base model path: ' + `getModelPath().getValue()`) + strVar.set('Base model path: ' + repr(getModelPath().getValue())) def checkForTexture(strVar = strVar): tex = loader.loadTexture(strVar.get()) @@ -2406,7 +2406,7 @@ class ParticlePanel(AppShell): if frame.valid: mStrVar.set(anim.getModelSource()) else: - mStrVar.set('Base model path: ' + `getModelPath().getValue()`) + mStrVar.set('Base model path: ' + repr(getModelPath().getValue())) mlf = lf @@ -2460,9 +2460,9 @@ class ParticlePanel(AppShell): for anim in [ren.getAnim(x) for x in range(ren.getNumAnims())]: if(anim.getSourceType() == SpriteAnim.STTexture): - w = self.createSpriteAnimationTextureWidget(self.rendererSpriteAnimationFrame, anim, `len(self.rendererSpriteAnimationWidgetList)`) + w = self.createSpriteAnimationTextureWidget(self.rendererSpriteAnimationFrame, anim, repr(len(self.rendererSpriteAnimationWidgetList))) else: - w = self.createSpriteAnimationNodeWidget(self.rendererSpriteAnimationFrame, anim, `len(self.rendererSpriteAnimationWidgetList)`) + w = self.createSpriteAnimationNodeWidget(self.rendererSpriteAnimationFrame, anim, repr(len(self.rendererSpriteAnimationWidgetList))) self.rendererSpriteAnimationWidgetList.append(w) # set animation info from panel into renderer @@ -2476,11 +2476,11 @@ class ParticlePanel(AppShell): widget = self.rendererSpriteAnimationWidgetList[x] if(widget and widget.valid): if(widget.animSourceType == SpriteAnim.STTexture): - texSource = self.getVariable('Sprite Renderer', `x` + ' Anim Texture').get() + texSource = self.getVariable('Sprite Renderer', repr(x) + ' Anim Texture').get() ren.addTextureFromFile(texSource) else: - modelSource = self.getVariable('Sprite Renderer', `x` + ' Anim Model').get() - nodeSource = self.getVariable('Sprite Renderer', `x` + ' Anim Node').get() + modelSource = self.getVariable('Sprite Renderer', repr(x) + ' Anim Model').get() + nodeSource = self.getVariable('Sprite Renderer', repr(x) + ' Anim Node').get() ren.addTextureFromNode(modelSource, nodeSource) ## FORCEGROUP COMMANDS ## @@ -2667,7 +2667,7 @@ class ParticlePanel(AppShell): count, force): def setVec(vec, f = force): f.setVector(vec[0], vec[1], vec[2]) - forceName = 'Vector Force-' + `count` + forceName = 'Vector Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) vec = force.getLocalVector() @@ -2679,7 +2679,7 @@ class ParticlePanel(AppShell): def createLinearRandomForceWidget(self, forcePage, pageName, count, force, type): - forceName = type + ' Force-' + `count` + forceName = type + ' Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) self.createForceActiveWidget(frame, pageName, forceName, force) @@ -2688,7 +2688,7 @@ class ParticlePanel(AppShell): count, force): def setCoef(coef, f = force): f.setCoef(coef) - forceName = 'Friction Force-' + `count` + forceName = 'Friction Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) self.createFloater(frame, pageName, forceName + ' Coef', @@ -2699,7 +2699,7 @@ class ParticlePanel(AppShell): def createLinearCylinderVortexForceWidget(self, forcePage, pageName, count, force): - forceName = 'Vortex Force-' + `count` + forceName = 'Vortex Force-' + repr(count) def setCoef(coef, f = force): f.setCoef(coef) def setLength(length, f = force): @@ -2738,7 +2738,7 @@ class ParticlePanel(AppShell): f.setForceCenter(Point3(vec[0], vec[1], vec[2])) def setRadius(radius, f = force): f.setRadius(radius) - forceName = type + ' Force-' + `count` + forceName = type + ' Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) var = self.createOptionMenu( diff --git a/direct/src/tkpanels/Placer.py b/direct/src/tkpanels/Placer.py index 4dd039555c..44d0d04728 100644 --- a/direct/src/tkpanels/Placer.py +++ b/direct/src/tkpanels/Placer.py @@ -509,7 +509,7 @@ class Placer(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + `nodePath.id()` + dictName = name + '-' + repr(nodePath.id()) if not dict.has_key(dictName): # Update combo box to include new item names.append(dictName) diff --git a/direct/src/tkwidgets/AppShell.py b/direct/src/tkwidgets/AppShell.py index c5013ca0de..3f024c58e5 100644 --- a/direct/src/tkwidgets/AppShell.py +++ b/direct/src/tkwidgets/AppShell.py @@ -84,7 +84,7 @@ class AppShell(Pmw.MegaWidget, DirectObject): self.parent.title(self['title']) # Create unique id AppShell.panelCount += 1 - self.id = self.appname + '-' + `AppShell.panelCount` + self.id = self.appname + '-' + repr(AppShell.panelCount) # Create a dictionary in the widgetDict to hold this panel's widgets self.widgetDict = widgetDict[self.id] = {} # And one to hold this panel's variables diff --git a/direct/src/tkwidgets/EntryScale.py b/direct/src/tkwidgets/EntryScale.py index 21bc89744d..59cbb3d928 100644 --- a/direct/src/tkwidgets/EntryScale.py +++ b/direct/src/tkwidgets/EntryScale.py @@ -91,7 +91,7 @@ class EntryScale(Pmw.MegaWidget): # Create the EntryScale's min max labels self.minLabel = self.createcomponent('minLabel', (), None, Label, self.minMaxFrame, - text = `self['min']`, + text = repr(self['min']), relief = FLAT, width = 5, anchor = W, @@ -118,7 +118,7 @@ class EntryScale(Pmw.MegaWidget): self.maxLabel = self.createcomponent('maxLabel', (), None, Label, self.minMaxFrame, - text = `self['max']`, + text = repr(self['max']), relief = FLAT, width = 5, anchor = E, @@ -140,7 +140,7 @@ class EntryScale(Pmw.MegaWidget): def askForLabel(self, event = None): newLabel = askstring(title = self['text'], prompt = 'New label:', - initialvalue = `self['text']`, + initialvalue = repr(self['text']), parent = self.interior()) if newLabel: self['text'] = newLabel @@ -148,7 +148,7 @@ class EntryScale(Pmw.MegaWidget): def askForMin(self, event = None): newMin = askfloat(title = self['text'], prompt = 'New min val:', - initialvalue = `self['min']`, + initialvalue = repr(self['min']), parent = self.interior()) if newMin: self.setMin(newMin) diff --git a/direct/src/tkwidgets/Tree.py b/direct/src/tkwidgets/Tree.py index 59e327be37..89979ae1b9 100644 --- a/direct/src/tkwidgets/Tree.py +++ b/direct/src/tkwidgets/Tree.py @@ -30,7 +30,7 @@ from pandac.PandaModules import * # Initialize icon directory ICONDIR = ConfigVariableSearchPath('model-path').findFile(Filename('icons')).toOsSpecific() if not os.path.isdir(ICONDIR): - raise RuntimeError, "can't find DIRECT icon directory (%s)" % `ICONDIR` + raise RuntimeError, "can't find DIRECT icon directory (%s)" % repr(ICONDIR) class TreeNode: