added traceParentCall; print fsm tre unfinished

This commit is contained in:
Dave Schuyler 2004-04-23 03:48:02 +00:00
parent a4a9c9e151
commit c85e84adc6

View File

@ -31,6 +31,18 @@ def indent(stream, numIndents, str):
stream.write(' ' * numIndents + str) stream.write(' ' * numIndents + str)
def writeFsmTree(instance, indent = 0):
if hasattr(instance, 'parentFSM'):
writeFsmTree(instance.parentFSM, indent-2)
elif hasattr(instance, 'fsm'):
name = ''
if hasattr(instance.fsm, 'state'):
name = instance.fsm.state.name
print "%s: %s"%(instance.fsm.name, name)
def traceFunctionCall(frame): def traceFunctionCall(frame):
""" """
@ -45,12 +57,16 @@ def traceFunctionCall(frame):
if co.co_flags & 4: n = n+1 if co.co_flags & 4: n = n+1
if co.co_flags & 8: n = n+1 if co.co_flags & 8: n = n+1
r=f.f_code.co_name+'(' r=f.f_code.co_name+'('
comma=0 # formatting, whether we should type a comma.
for i in range(n): for i in range(n):
name = co.co_varnames[i] name = co.co_varnames[i]
if name=='self': if name=='self':
continue continue
if i: if comma:
r+=', ' r+=', '
else:
# ok, we skipped the first one, the rest get commas:
comma=1
r+=name r+=name
r+='=' r+='='
if dict.has_key(name): if dict.has_key(name):
@ -62,6 +78,9 @@ def traceFunctionCall(frame):
else: r+="*** undefined ***" else: r+="*** undefined ***"
return r+')' return r+')'
def traceParentCall():
return traceFunctionCall(sys._getframe(2))
def printThisCall(): def printThisCall():
print traceFunctionCall(sys._getframe(1)) print traceFunctionCall(sys._getframe(1))
return 1 # to allow "assert printThisCall()" return 1 # to allow "assert printThisCall()"