mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
added safeTypeName and histogramDict
This commit is contained in:
parent
384a2570a8
commit
5545aa6ce7
@ -32,7 +32,7 @@ __all__ = ['enumerate', 'unique', 'indent', 'nonRepeatingRandomList',
|
||||
'pandaBreak','pandaTrace','formatTimeCompact','DestructiveScratchPad',
|
||||
'deeptype','getProfileResultString','StdoutCapture','StdoutPassthrough',
|
||||
'Averager', 'getRepository', 'formatTimeExact', 'startSuperLog', 'endSuperLog',
|
||||
'typeName', ]
|
||||
'typeName', 'safeTypeName', 'histogramDict', ]
|
||||
|
||||
import types
|
||||
import string
|
||||
@ -3859,6 +3859,24 @@ def typeName(o):
|
||||
else:
|
||||
return o.__name__
|
||||
|
||||
def safeTypeName(o):
|
||||
try:
|
||||
return typeName(o)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
return type(o)
|
||||
except:
|
||||
pass
|
||||
return '<failed safeTypeName()>'
|
||||
|
||||
def histogramDict(l):
|
||||
d = {}
|
||||
for e in l:
|
||||
d.setdefault(e, 0)
|
||||
d[e] += 1
|
||||
return d
|
||||
|
||||
import __builtin__
|
||||
__builtin__.Functor = Functor
|
||||
__builtin__.Stack = Stack
|
||||
@ -3913,3 +3931,5 @@ __builtin__.Default = Default
|
||||
__builtin__.isInteger = isInteger
|
||||
__builtin__.configIsToday = configIsToday
|
||||
__builtin__.typeName = typeName
|
||||
__builtin__.safeTypeName = safeTypeName
|
||||
__builtin__.histogramDict = histogramDict
|
||||
|
Loading…
x
Reference in New Issue
Block a user