Browse Source

Fixes for Python 3

rdb 11 years ago
parent
commit
79430f6bc5
2 changed files with 8 additions and 10 deletions
  1. 5 8
      direct/src/actor/Actor.py
  2. 3 2
      direct/src/interval/FunctionInterval.py

+ 5 - 8
direct/src/actor/Actor.py

@@ -566,7 +566,7 @@ class Actor(DirectObject, NodePath):
         # and sort them every time somebody asks for the list
         # and sort them every time somebody asks for the list
         self.__sortedLODNames = self.__partBundleDict.keys()
         self.__sortedLODNames = self.__partBundleDict.keys()
         # Reverse sort the doing a string->int
         # Reverse sort the doing a string->int
-        def sortFunc(x, y):
+        def sortKey(x):
             if not str(x).isdigit():
             if not str(x).isdigit():
                 smap = {'h':3,
                 smap = {'h':3,
                         'm':2,
                         'm':2,
@@ -574,19 +574,16 @@ class Actor(DirectObject, NodePath):
                         'f':0}
                         'f':0}
 
 
                 """
                 """
-                sx = smap.get(x[0],None)
-                sy = smap.get(y[0],None)
+                sx = smap.get(x[0], None)
 
 
                 if sx is None:
                 if sx is None:
                     self.notify.error('Invalid lodName: %s' % x)
                     self.notify.error('Invalid lodName: %s' % x)
-                if sy is None:
-                    self.notify.error('Invalid lodName: %s' % y)
                 """
                 """
-                return cmp(smap[y[0]], smap[x[0]])
+                return smap[x[0]]
             else:
             else:
-                return cmp (int(y), int(x))
+                return int(x)
 
 
-        self.__sortedLODNames.sort(sortFunc)
+        self.__sortedLODNames.sort(key=sortKey, reverse=True)
 
 
     def getLODNames(self):
     def getLODNames(self):
         """
         """

+ 3 - 2
direct/src/interval/FunctionInterval.py

@@ -57,9 +57,10 @@ class FunctionInterval(Interval.Interval):
         self.function = function
         self.function = function
             
             
         # Create a unique name for the interval if necessary
         # Create a unique name for the interval if necessary
-        if (name == None):
+        if name is None:
             name = self.makeUniqueName(function)
             name = self.makeUniqueName(function)
-        assert isinstance(name, types.StringType)
+        assert isinstance(name, str)
+
         # Record any arguments
         # Record any arguments
         self.extraArgs = extraArgs
         self.extraArgs = extraArgs
         self.kw = kw
         self.kw = kw