added config variable support to report

This commit is contained in:
Josh Wilson 2007-01-17 00:51:34 +00:00
parent 3f13ca0b90
commit 4ec281ba89

View File

@ -24,7 +24,7 @@ __all__ = ['enumerate', 'unique', 'indent', 'nonRepeatingRandomList',
'ScratchPad', 'Sync', 'RefCounter', 'itype', 'getNumberedTypedString',
'printNumberedTyped', 'DelayedCall', 'DelayedFunctor',
'FrameDelayedCallback', 'ArgumentEater', 'ClassTree', 'getBase',
'superFlattenShip','report','HotkeyBreaker']
'superFlattenShip','HotkeyBreaker']
import types
import string
@ -2419,17 +2419,10 @@ class ClassTree:
return self._getStr()
def report(types = [], notifyFunc = None, overrideDev = False):
if overrideDev:
__dev__ = 1
def report(types = [], notifyFunc = None, dConfigParam = ''):
try:
__dev__
except NameError:
__dev__ = False
if __dev__:
def decorator(f):
__dev__
def wrap(*args,**kwargs):
aargs = args
kkwargs = kwargs
@ -2443,8 +2436,12 @@ def report(types = [], notifyFunc = None, overrideDev = False):
outStr = f.func_name + rArgs
if 'frameCount' in types:
outStr = `globalClock.getFrameCount()` + ': ' + outStr
outStr = '%8d : %s' % (globalClock.getFrameCount(), outStr)
if 'timeStamp' in types:
outStr = '%5.3f : %s' % (globalClock.getFrameTime(), outStr)
if not dConfigParam or (config.GetBool(dConfigParam, 0)):
if notifyFunc:
notifyFunc(outStr)
else:
@ -2452,11 +2449,14 @@ def report(types = [], notifyFunc = None, overrideDev = False):
return f(*args,**kwargs)
wrap.func_name = f.func_name
wrap.func_dict = f.func_dict
wrap.func_doc = f.func_doc
return wrap
else:
except NameError,e:
print e
print 'Error decorating %s in %s with @report' % (f.func_name, f.__module__)
def decorator(f):
return f