mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
added config variable support to report
This commit is contained in:
parent
3f13ca0b90
commit
4ec281ba89
@ -24,7 +24,7 @@ __all__ = ['enumerate', 'unique', 'indent', 'nonRepeatingRandomList',
|
|||||||
'ScratchPad', 'Sync', 'RefCounter', 'itype', 'getNumberedTypedString',
|
'ScratchPad', 'Sync', 'RefCounter', 'itype', 'getNumberedTypedString',
|
||||||
'printNumberedTyped', 'DelayedCall', 'DelayedFunctor',
|
'printNumberedTyped', 'DelayedCall', 'DelayedFunctor',
|
||||||
'FrameDelayedCallback', 'ArgumentEater', 'ClassTree', 'getBase',
|
'FrameDelayedCallback', 'ArgumentEater', 'ClassTree', 'getBase',
|
||||||
'superFlattenShip','report','HotkeyBreaker']
|
'superFlattenShip','HotkeyBreaker']
|
||||||
|
|
||||||
import types
|
import types
|
||||||
import string
|
import string
|
||||||
@ -2419,17 +2419,10 @@ class ClassTree:
|
|||||||
return self._getStr()
|
return self._getStr()
|
||||||
|
|
||||||
|
|
||||||
def report(types = [], notifyFunc = None, overrideDev = False):
|
def report(types = [], notifyFunc = None, dConfigParam = ''):
|
||||||
if overrideDev:
|
|
||||||
__dev__ = 1
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
__dev__
|
|
||||||
except NameError:
|
|
||||||
__dev__ = False
|
|
||||||
|
|
||||||
if __dev__:
|
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
|
__dev__
|
||||||
def wrap(*args,**kwargs):
|
def wrap(*args,**kwargs):
|
||||||
aargs = args
|
aargs = args
|
||||||
kkwargs = kwargs
|
kkwargs = kwargs
|
||||||
@ -2443,8 +2436,12 @@ def report(types = [], notifyFunc = None, overrideDev = False):
|
|||||||
outStr = f.func_name + rArgs
|
outStr = f.func_name + rArgs
|
||||||
|
|
||||||
if 'frameCount' in types:
|
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:
|
if notifyFunc:
|
||||||
notifyFunc(outStr)
|
notifyFunc(outStr)
|
||||||
else:
|
else:
|
||||||
@ -2452,11 +2449,14 @@ def report(types = [], notifyFunc = None, overrideDev = False):
|
|||||||
|
|
||||||
return f(*args,**kwargs)
|
return f(*args,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
wrap.func_name = f.func_name
|
wrap.func_name = f.func_name
|
||||||
wrap.func_dict = f.func_dict
|
wrap.func_dict = f.func_dict
|
||||||
wrap.func_doc = f.func_doc
|
wrap.func_doc = f.func_doc
|
||||||
return wrap
|
return wrap
|
||||||
else:
|
except NameError,e:
|
||||||
|
print e
|
||||||
|
print 'Error decorating %s in %s with @report' % (f.func_name, f.__module__)
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user