Browse Source

removed parens from asserts

Dave Schuyler 19 years ago
parent
commit
64d22156c7

+ 1 - 1
direct/src/controls/ControlManager.py

@@ -221,7 +221,7 @@ class ControlManager:
             inputState.force("jump", 0)
 
     def monitor(self, foo):
-        #assert(self.debugPrint("monitor()"))
+        #assert self.debugPrint("monitor()")
         #if 1:
         #    airborneHeight=self.avatar.getAirborneHeight()
         #    onScreenDebug.add("airborneHeight", "% 10.4f"%(airborneHeight,))

+ 1 - 1
direct/src/controls/DevWalker.py

@@ -46,7 +46,7 @@ class DevWalker(DirectObject.DirectObject):
         self.avatarControlRotateSpeed=rotate
 
     def getSpeeds(self):
-        #assert(self.debugPrint("getSpeeds()"))
+        #assert self.debugPrint("getSpeeds()")
         return (self.speed, self.rotationSpeed, self.slideSpeed)
 
     def setAvatar(self, avatar):

+ 3 - 3
direct/src/controls/InputState.py

@@ -37,9 +37,9 @@ class InputState(DirectObject.DirectObject):
             events occur.
         See Also: ignore()
         """
-        assert(self.debugPrint(
+        assert self.debugPrint(
             "watch(name=%s, eventOn=%s, eventOff=%s, default=%s)"%(
-            name, eventOn, eventOff, default)))
+            name, eventOn, eventOff, default))
         self.accept(eventOn, self.set, [name, 1])
         self.accept(eventOff, self.set, [name, 0])
         self.state[name] = default
@@ -96,7 +96,7 @@ class InputState(DirectObject.DirectObject):
         """
         returns 0, 1
         """
-        #assert(self.debugPrint("isSet(name=%s)"%(name)))
+        #assert self.debugPrint("isSet(name=%s)"%(name))
         r = self.forcing.get(name)
         if r is not None:
             return r

+ 1 - 1
direct/src/controls/NonPhysicsWalker.py

@@ -45,7 +45,7 @@ class NonPhysicsWalker(DirectObject.DirectObject):
         self.avatarControlRotateSpeed=rotate
 
     def getSpeeds(self):
-        #assert(self.debugPrint("getSpeeds()"))
+        #assert self.debugPrint("getSpeeds()")
         return (self.speed, self.rotationSpeed, self.slideSpeed)
 
     def setAvatar(self, avatar):

+ 9 - 7
direct/src/controls/PhysicsWalker.py

@@ -35,8 +35,9 @@ class PhysicsWalker(DirectObject.DirectObject):
     # special methods
     def __init__(self, gravity = -32.1740, standableGround=0.707,
             hardLandingForce=16.0):
-        assert(self.debugPrint("PhysicsWalker(gravity=%s, standableGround=%s)"%(
-                gravity, standableGround)))
+        assert self.debugPrint(
+            "PhysicsWalker(gravity=%s, standableGround=%s)"%(
+            gravity, standableGround))
         DirectObject.DirectObject.__init__(self)
         self.__gravity=gravity
         self.__standableGround=standableGround
@@ -115,7 +116,7 @@ class PhysicsWalker(DirectObject.DirectObject):
         self.avatarControlRotateSpeed=rotate
 
     def getSpeeds(self):
-        #assert(self.debugPrint("getSpeeds()"))
+        #assert self.debugPrint("getSpeeds()")
         return (self.__speed, self.__rotationSpeed)
 
     def setAvatar(self, avatar):
@@ -322,7 +323,7 @@ class PhysicsWalker(DirectObject.DirectObject):
             print "failed load of physics indicator"
 
     def avatarPhysicsIndicator(self, task):
-        #assert(self.debugPrint("avatarPhysicsIndicator()"))
+        #assert self.debugPrint("avatarPhysicsIndicator()")
         # Velocity:
         self.physVelocityIndicator.setPos(self.avatarNodePath, 0.0, 0.0, 6.0)
         physObject=self.actorNode.getPhysicsObject()
@@ -379,8 +380,9 @@ class PhysicsWalker(DirectObject.DirectObject):
                 self.oneTimeCollide()
 
     def getCollisionsActive(self):
-        assert(self.debugPrint("getCollisionsActive() returning=%s"%(
-            self.collisionsActive,)))
+        assert self.debugPrint(
+            "getCollisionsActive() returning=%s"%(
+            self.collisionsActive,))
         return self.collisionsActive
 
     def placeOnFloor(self):
@@ -438,7 +440,7 @@ class PhysicsWalker(DirectObject.DirectObject):
                 onScreenDebug.append("localAvatar pos = %s\n"%(base.localAvatar.getPos().pPrintValues(),))
                 onScreenDebug.append("localAvatar h = % 10.4f\n"%(base.localAvatar.getH(),))
                 onScreenDebug.append("localAvatar anim = %s\n"%(base.localAvatar.animFSM.getCurrentState().getName(),))
-        #assert(self.debugPrint("handleAvatarControls(task=%s)"%(task,)))
+        #assert self.debugPrint("handleAvatarControls(task=%s)"%(task,))
         physObject=self.actorNode.getPhysicsObject()
         #rotAvatarToPhys=Mat3.rotateMatNormaxis(-self.avatarNodePath.getH(), Vec3.up())
         #rotPhysToAvatar=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())

+ 3 - 3
direct/src/controls/ShipPilot.py

@@ -74,7 +74,7 @@ class ShipPilot(PhysicsWalker):
         self.avatarControlRotateSpeed=rotate
 
     def getSpeeds(self):
-        #assert(self.debugPrint("getSpeeds()"))
+        #assert self.debugPrint("getSpeeds()")
         return (self.__speed, self.__rotationSpeed)
 
     def setAvatar(self, ship):
@@ -444,7 +444,7 @@ class ShipPilot(PhysicsWalker):
             print "failed load of physics indicator"
 
     def avatarPhysicsIndicator(self, task):
-        #assert(self.debugPrint("avatarPhysicsIndicator()"))
+        #assert self.debugPrint("avatarPhysicsIndicator()")
         # Velocity:
         self.physVelocityIndicator.setPos(self.avatarNodePath, 0.0, 0.0, 6.0)
         physObject=self.actorNode.getPhysicsObject()
@@ -614,7 +614,7 @@ class ShipPilot(PhysicsWalker):
                     base.localAvatar.getHpr().pPrintValues(),))
                 #onScreenDebug.append("localAvatar anim = %s\n"%(
                 #    base.localAvatar.animFSM.getCurrentState().getName(),))
-        #assert(self.debugPrint("handleAvatarControls(task=%s)"%(task,)))
+        #assert self.debugPrint("handleAvatarControls(task=%s)"%(task,))
         physObject=self.actorNode.getPhysicsObject()
         #rotAvatarToPhys=Mat3.rotateMatNormaxis(
         #    -self.avatarNodePath.getH(), Vec3.up())

+ 3 - 3
direct/src/directutil/Verify.py

@@ -7,7 +7,7 @@ You can use verify() just like assert, with these small differences:
       e.g.:
         assert foo  # OK
         verify foo  # Error
-        assert(foo) # OK
+        assert foo  # Not Recomended (may be interpreted as a tuple)
         verify(foo) # OK
     - verify() will print something like the following before raising
       an exception:
@@ -24,12 +24,12 @@ verify() will also throw an AssertionError, but you can ignore that if you
 like (I don't suggest trying to catch it, it's just doing it so that it can
 replace assert more fully).
 
-Please do not use assert() for things that you want run on release builds.
+Please do not use assert for things that you want run on release builds.
 That is a bad thing to do.  One of the main reasons that assert exists
 is to stip out debug code from a release build.  The fact that it throws
 an exception can get it mistaken for an error handler.  If your code
 needs to handle an error or throw an exception, you should do that
-(and not just assert() for it).
+(and not just assert for it).
 
 If you want to be a super keen software engineer then avoid using verify().
 If you want to be, or already are, a super keen software engineer, but

+ 2 - 2
direct/src/distributed/ClientRepository.py

@@ -171,7 +171,7 @@ class ClientRepository(ClientRepositoryBase):
             # ...it is in our dictionary.
             # Just update it.
             distObj = self.doId2do[doId]
-            assert(distObj.dclass == dclass)
+            assert distObj.dclass == dclass
             distObj.generate()
             distObj.updateRequiredFields(dclass, di)
             # updateRequiredFields calls announceGenerate
@@ -179,7 +179,7 @@ class ClientRepository(ClientRepositoryBase):
             # ...it is in the cache.
             # Pull it out of the cache:
             distObj = self.cache.retrieve(doId)
-            assert(distObj.dclass == dclass)
+            assert distObj.dclass == dclass
             # put it in the dictionary:
             self.doId2do[doId] = distObj
             # and update it.

+ 8 - 6
direct/src/distributed/DistributedObject.py

@@ -130,15 +130,17 @@ class DistributedObject(DistributedObjectBase):
             self.notify.error("Somebody decremented delayDelete for doId %s without incrementing"
                               % (self.doId))
         elif (self.delayDeleteCount == 0):
-            assert(self.notify.debug("delayDeleteCount for doId %s now 0"
-                                     % (self.doId)))
+            assert self.notify.debug(
+                "delayDeleteCount for doId %s now 0" % (self.doId))
             if self.deleteImminent:
-                assert(self.notify.debug("delayDeleteCount for doId %s -- deleteImminent"
-                                         % (self.doId)))
+                assert self.notify.debug(
+                    "delayDeleteCount for doId %s -- deleteImminent" %
+                    (self.doId))
                 self.disableAnnounceAndDelete()
         else:
-            self.notify.debug("delayDeleteCount for doId %s now %s"
-                              % (self.doId, self.delayDeleteCount))
+            self.notify.debug(
+                "delayDeleteCount for doId %s now %s" %
+                (self.doId, self.delayDeleteCount))
 
         # Return the count just for kicks
         return self.delayDeleteCount

+ 9 - 6
direct/src/distributed/DistributedObjectOV.py

@@ -85,15 +85,18 @@ class DistributedObjectOV(DistributedObjectBase):
             self.notify.error("Somebody decremented delayDelete for doId %s without incrementing"
                               % (self.doId))
         elif (self.delayDeleteCount == 0):
-            assert(self.notify.debug("delayDeleteCount for doId %s now 0"
-                                     % (self.doId)))
+            assert self.notify.debug(
+                "delayDeleteCount for doId %s now 0" %
+                (self.doId))
             if self.deleteImminent:
-                assert(self.notify.debug("delayDeleteCount for doId %s -- deleteImminent"
-                                         % (self.doId)))
+                assert self.notify.debug(
+                    "delayDeleteCount for doId %s -- deleteImminent" %
+                    (self.doId))
                 self.disableAnnounceAndDelete()
         else:
-            self.notify.debug("delayDeleteCount for doId %s now %s"
-                              % (self.doId, self.delayDeleteCount))
+            self.notify.debug(
+                "delayDeleteCount for doId %s now %s" %
+                (self.doId, self.delayDeleteCount))
 
         # Return the count just for kicks
         return self.delayDeleteCount

+ 12 - 8
direct/src/fsm/ClassicFSM.py

@@ -274,21 +274,24 @@ class ClassicFSM(DirectObject):
         elif (aStateName == self.__finalState.getName()):
             if (self.__currentState == self.__finalState):
                 # Do not do the transition if we are already in the final state
-                assert(ClassicFSM.notify.debug("[%s]: already in final state: %s" %
-                                               (self.__name, aStateName)))
+                assert ClassicFSM.notify.debug(
+                    "[%s]: already in final state: %s" %
+                    (self.__name, aStateName))
                 return 1
             else:
                 # Force a transition to allow for cleanup
-                assert(ClassicFSM.notify.debug("[%s]: implicit transition to final state: %s" %
-                                               (self.__name, aStateName)))
+                assert ClassicFSM.notify.debug(
+                    "[%s]: implicit transition to final state: %s" %
+                    (self.__name, aStateName))
                 self.__transition(aState,
                                   enterArgList,
                                   exitArgList)
                 return 1
         # are we already in this state?
         elif (aStateName == self.__currentState.getName()):
-            assert(ClassicFSM.notify.debug("[%s]: already in state %s and no self transition" %
-                                           (self.__name, aStateName)))
+            assert ClassicFSM.notify.debug(
+                "[%s]: already in state %s and no self transition" %
+                (self.__name, aStateName))
             return 0
         else:
             msg = ("[%s]: no transition exists from %s to %s" %
@@ -346,8 +349,9 @@ class ClassicFSM(DirectObject):
         if transitionDefined:
             return self.request(aStateName, enterArgList, exitArgList)
         else:
-            assert(ClassicFSM.notify.debug("[%s]: condition_request: %s, transition doesnt exist" %
-                                           (self.__name, aStateName)))
+            assert ClassicFSM.notify.debug(
+                "[%s]: condition_request: %s, transition doesnt exist" %
+                (self.__name, aStateName))
             return 0
 
     def view(self):

+ 5 - 4
direct/src/fsm/FourStateAI.py

@@ -91,9 +91,9 @@ class FourStateAI:
         off (and so is state 2 which is oposite of state 4 and therefore 
         oposite of 'on').
         """
-        assert(self.debugPrint(
+        assert self.debugPrint(
                 "FourStateAI(names=%s, durations=%s)"
-                %(names, durations)))
+                %(names, durations))
         self.doLaterTask = None
         self.stateIndex = 0
         assert len(names) == 5
@@ -195,8 +195,9 @@ class FourStateAI:
         self.sendState()
     
     def enterStateN(self, stateIndex, nextStateIndex):
-        assert(self.debugPrint("enterStateN(stateIndex=%s, nextStateIndex=%s)"%(
-            stateIndex, nextStateIndex)))
+        assert self.debugPrint(
+            "enterStateN(stateIndex=%s, nextStateIndex=%s)"%
+            (stateIndex, nextStateIndex))
         self.stateIndex = stateIndex
         self.nextStateIndex = nextStateIndex
         self.distributeStateChange()