mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
distributed: type(x) == types.FooType
-> inspect.isfoo(x)
This is more compatible across Python 2 vs. 3. [skip ci]
This commit is contained in:
parent
8ad4c8e23c
commit
ac8417ffdf
@ -7,7 +7,7 @@ from direct.distributed.DoCollectionManager import DoCollectionManager
|
|||||||
from direct.showbase import GarbageReport
|
from direct.showbase import GarbageReport
|
||||||
from .PyDatagramIterator import PyDatagramIterator
|
from .PyDatagramIterator import PyDatagramIterator
|
||||||
|
|
||||||
import types
|
import inspect
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
__all__ = ["ConnectionRepository", "GCTrigger"]
|
__all__ = ["ConnectionRepository", "GCTrigger"]
|
||||||
@ -327,13 +327,13 @@ class ConnectionRepository(
|
|||||||
if classDef is None:
|
if classDef is None:
|
||||||
self.notify.debug("No class definition for %s." % (className))
|
self.notify.debug("No class definition for %s." % (className))
|
||||||
else:
|
else:
|
||||||
if type(classDef) == types.ModuleType:
|
if inspect.ismodule(classDef):
|
||||||
if not hasattr(classDef, className):
|
if not hasattr(classDef, className):
|
||||||
self.notify.warning("Module %s does not define class %s." % (className, className))
|
self.notify.warning("Module %s does not define class %s." % (className, className))
|
||||||
continue
|
continue
|
||||||
classDef = getattr(classDef, className)
|
classDef = getattr(classDef, className)
|
||||||
|
|
||||||
if type(classDef) != types.ClassType and type(classDef) != types.TypeType:
|
if inspect.isclass(classDef):
|
||||||
self.notify.error("Symbol %s is not a class name." % (className))
|
self.notify.error("Symbol %s is not a class name." % (className))
|
||||||
else:
|
else:
|
||||||
dclass.setClassDef(classDef)
|
dclass.setClassDef(classDef)
|
||||||
@ -388,7 +388,7 @@ class ConnectionRepository(
|
|||||||
if classDef is None:
|
if classDef is None:
|
||||||
self.notify.error("No class definition for %s." % className)
|
self.notify.error("No class definition for %s." % className)
|
||||||
else:
|
else:
|
||||||
if type(classDef) == types.ModuleType:
|
if inspect.ismodule(classDef):
|
||||||
if not hasattr(classDef, className):
|
if not hasattr(classDef, className):
|
||||||
self.notify.error("Module %s does not define class %s." % (className, className))
|
self.notify.error("Module %s does not define class %s." % (className, className))
|
||||||
classDef = getattr(classDef, className)
|
classDef = getattr(classDef, className)
|
||||||
|
@ -7,6 +7,8 @@ from direct.task import Task
|
|||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed.PyDatagram import PyDatagram
|
from direct.distributed.PyDatagram import PyDatagram
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
class ServerRepository:
|
class ServerRepository:
|
||||||
|
|
||||||
@ -273,12 +275,12 @@ class ServerRepository:
|
|||||||
if classDef == None:
|
if classDef == None:
|
||||||
self.notify.debug("No class definition for %s." % (className))
|
self.notify.debug("No class definition for %s." % (className))
|
||||||
else:
|
else:
|
||||||
if type(classDef) == types.ModuleType:
|
if inspect.ismodule(classDef):
|
||||||
if not hasattr(classDef, className):
|
if not hasattr(classDef, className):
|
||||||
self.notify.error("Module %s does not define class %s." % (className, className))
|
self.notify.error("Module %s does not define class %s." % (className, className))
|
||||||
classDef = getattr(classDef, className)
|
classDef = getattr(classDef, className)
|
||||||
|
|
||||||
if type(classDef) != types.ClassType and type(classDef) != types.TypeType:
|
if inspect.isclass(classDef):
|
||||||
self.notify.error("Symbol %s is not a class name." % (className))
|
self.notify.error("Symbol %s is not a class name." % (className))
|
||||||
else:
|
else:
|
||||||
dclass.setClassDef(classDef)
|
dclass.setClassDef(classDef)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user