mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
lineage
This commit is contained in:
parent
429a075c79
commit
b78fb88cf3
@ -141,6 +141,33 @@ def printThisCall():
|
|||||||
return 1 # to allow "assert printThisCall()"
|
return 1 # to allow "assert printThisCall()"
|
||||||
|
|
||||||
|
|
||||||
|
if __debug__:
|
||||||
|
def lineage(obj, verbose=0, indent=0):
|
||||||
|
"""
|
||||||
|
return instance or class name in as a multiline string.
|
||||||
|
|
||||||
|
Usage: print lineage(foo)
|
||||||
|
|
||||||
|
(Based on getClassLineage())
|
||||||
|
"""
|
||||||
|
r=""
|
||||||
|
if type(obj) == types.ListType:
|
||||||
|
r+=(" "*indent)+"python list\n"
|
||||||
|
elif type(obj) == types.DictionaryType:
|
||||||
|
r+=(" "*indent)+"python dictionary\n"
|
||||||
|
elif type(obj) == types.ModuleType:
|
||||||
|
r+=(" "*indent)+str(obj)+"\n"
|
||||||
|
elif type(obj) == types.InstanceType:
|
||||||
|
r+=lineage(obj.__class__, verbose, indent)
|
||||||
|
elif type(obj) == types.ClassType:
|
||||||
|
r+=(" "*indent)
|
||||||
|
if verbose:
|
||||||
|
r+=obj.__module__+"."
|
||||||
|
r+=obj.__name__+"\n"
|
||||||
|
for c in obj.__bases__:
|
||||||
|
r+=lineage(c, verbose, indent+2)
|
||||||
|
return r
|
||||||
|
|
||||||
def tron():
|
def tron():
|
||||||
sys.settrace(trace)
|
sys.settrace(trace)
|
||||||
def trace(frame, event, arg):
|
def trace(frame, event, arg):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user