Panda3D

- Main Page
- Packages
- Classes

- Packages
- Package Functions

Classes | Functions | Variables

# Package showbase.PythonUtil

## Classes
class | AlphabetCounter
class | ArgumentEater
class | Averager
class | ClassTree
class | Default
class | DelayedCall
class | DelayedFunctor
class | DerivedPOD
class | DestructiveScratchPad
class | Enum
class | EnumIter
class | FrameDelayedCall
class | Functor
class | GoldenRectangle
class | HierarchyException
class | HotkeyBreaker
class | HTMLStringToElements
class | MiniLog
class | MiniLogSentry
class | ParamObj
class | ParamObjTest
class | POD
class | PODtest
class | PriorityCallbacks
class | PStatScope
class | Queue
class | RefCounter
class | ScratchPad
class | SerialMaskedGen
class | SerialNumGen
class | Signature
class | Singleton
class | SingletonError
class | Stack
class | StackTrace
class | StdoutCapture
class | StdoutPassthrough
class | SubframeCall
class | Sync
## Functions
def | a
def | addListsByValue
def | adjust
def | appendStr
def | average
def | b
def | baseLineCheck
def | binaryRepr
def | boolEqual
def | bound
def | bpdbGetEnabled
def | c
def | callerInfo
def | choice
def | clampScalar
def | closestDestAngle
def | closestDestAngle2
def | configIsToday
def | contains
def | convertTree
def | deeptype
def | describeException
def | difference
def | diffSinceBaseLine
def | disjoint
def | doc
def | encodedUtf8
def | endSuperLog
def | enumerate
def | exceptionLogged
def | extractProfile
def | fastRepr
def | findPythonModule
def | fitDestAngle2Src
def | fitSrcAngle2Dest
def | flywheel
def | formatElapsedSeconds
def | formatTimeCompact
def | formatTimeExact
def | get_all_objects
def | getAnnounceGenerateTime
def | getBase
def | getClassLineage
def | getIdList
def | getNumberedTypedSortedString
def | getNumberedTypedSortedStringWithReferrers
def | getNumberedTypedSortedStringWithReferrersGen
def | getNumberedTypedString
def | getProfileResultString
def | getRepository
def | getSetter
def | getSetterName
def | getShortestRotation
def | getTotalAnnounceTime
def | getTree
def | histogramDict
def | indent
def | intersection
def | invertDict
def | invertDictLossless
def | isDefaultValue
def | isInteger
def | itype
def | lerp
def | lineage
def | lineInfo
def | lineTag
def | lineupPos
def | list2dict
def | listToIndex2item
def | listToItem2index
def | logBlock
def | logMethodCalls
def | loopGen
def | makeFlywheelGen
def | makeList
def | makeTuple
def | mostDerivedLast
def | nonRepeatingRandomList
def | normalDistrib
def | notNone
def | nullGen
def | pandaBreak
def | pandaTrace
def | pdir
def | pivotScalar
def | pretty_print
def | printListEnum
def | printListEnumGen
def | printNumberedTyped
def | printNumberedTypes
def | printNumberedTypesGen
def | printProfile
def | printReverseStack
def | printStack
def | printThisCall
def | printVerboseStack
def | profiled
def | profileFunc
def | pstatcollect
def | quickProfile
def | r_add_chain
def | r_convertTree
def | r_pretty_print
def | randFloat
def | randInt32
def | randUint31
def | randUint32
def | recordCreationStack
def | recordCreationStackStr
def | recordFunctorCreationStacks
def | reduceAngle
def | repeatableRepr
def | replace
def | report
def | safeRepr
def | safeReprTypeOnFail
def | safeTypeName
def | sameElements
def | serialNum
def | setupPdb
def | solveQuadratic
def | stackEntryInfo
def | startProfile
def | startSuperLog
def | str2elements
def | tagRepr
def | tagWithCaller
def | testAlphabetCounter
def | trace
def | traceFunctionCall
def | traceParentCall
def | troff
def | tron
def | typeName
def | u2ascii
def | unescapeHtmlString
def | unicodeUtf8
def | union
def | unique
def | uniqueElements
def | uniqueName
def | weightedChoice
def | weightedRand
def | writeFsmTree
## Variables
list | __all__
int | __report_indent = 3
| _creationStackTrace
| _creationStackTraceStrLst
int | _KEY_DICT = 8
int | _POS_LIST = 4
string | _ProfileResultStr = ''
tuple | _serialGen = SerialNumGen()
dictionary | baseLine = {}
tuple | bItem = pc.add(b)
tuple | bpdb = BpDb.BpDb()
| clamp = bound
| dtoolSuperBase = None
| enumerate = __builtin__.enumerate
| exceptionLoggedNotify = None
tuple | f = flywheel(['a','b','c','d'], countList=[11,20,3,4])
| ftc = formatTimeCompact
| fte = formatTimeExact
| ftype = None
| globalPdb = None
tuple | GoldenRatio = (1. + math.sqrt(5.))
list | l = []
list | movedDumpFuncs = []
list | movedLoadFuncs = []
list | movedOpenFuncs = []
dictionary | obj2count = {}
tuple | p2 = PODtest()
dictionary | packageMap
tuple | pc = PriorityCallbacks()
dictionary | profileFilename2file = {}
dictionary | profileFilename2marshalData = {}
tuple | profileFilenameList = Stack()
tuple | profileFilenames = set()
string | PyUtilProfileDefaultFilename = 'profiledata'
int | PyUtilProfileDefaultLines = 80
list | PyUtilProfileDefaultSorts = ['cumulative', 'time', 'calls']
tuple | q = Queue()
| rad180 = math.pi
float | rad270 = 1.5
int | rad360 = 2
int | rad90 = 2
tuple | s = ScratchPad()
| safeReprNotify = None
tuple | ScalarTypes = (types.FloatType, types.IntType, types.LongType)
| superLogFile = None
| traceCalled = False

## Detailed Description

    Undocumented Module

## Function Documentation

def showbase.PythonUtil.a | ( |  | l = `l` | ) |

def showbase.PythonUtil.addListsByValue | ( |  | a,
|  |  | b
| ) |  |

    returns a new array containing the sums of the two array arguments
    (c[0] = a[0 + b[0], etc.)

def showbase.PythonUtil.adjust | ( |  | command = `None`,
|  |  | dim = `1`,
|  |  | parent = `None`,
|  |  | kw
| ) |  |

    adjust(command = None, parent = None, **kw)
    Popup and entry scale to adjust a parameter

    Accepts any Slider keyword argument.  Typical arguments include:
    command: The one argument command to execute
    min: The min value of the slider
    max: The max value of the slider
    resolution: The resolution of the slider
    text: The label on the slider

    These values can be accessed and/or changed after the fact
    >>> vg = adjust()
    >>> vg['min']
    0.0
    >>> vg['min'] = 10.0
    >>> vg['min']
    10.0

def showbase.PythonUtil.appendStr | ( |  | obj,
|  |  | st
| ) |  |

    adds a string onto the __str__ output of an instance

def showbase.PythonUtil.average | ( |  | args | ) |

    returns simple average of list of values

def showbase.PythonUtil.b | ( |  | l = `l` | ) |

def showbase.PythonUtil.baseLineCheck | ( |  | ) |

def showbase.PythonUtil.binaryRepr | ( |  | number,
|  |  | max_length = `32`
| ) |  |

def showbase.PythonUtil.boolEqual | ( |  | a,
|  |  | b
| ) |  |

    returns true if a and b are both true or both false.
    returns false otherwise
    (a.k.a. xnor -- eXclusive Not OR).

def showbase.PythonUtil.bound | ( |  | value,
|  |  | bound1,
|  |  | bound2
| ) |  |

    returns value if value is between bound1 and bound2
    otherwise returns bound that is closer to value

def showbase.PythonUtil.bpdbGetEnabled | ( |  | ) |

def showbase.PythonUtil.c | ( |  | l = `l` | ) |

def showbase.PythonUtil.callerInfo | ( |  | baseFileName = `1`,
|  |  | howFarBack = `0`
| ) |  |

    returns the sourcefilename, line number, and function name of the
    caller of the function that called this function
    (answers the question: 'hey callerInfo, who called me?')
    see stackEntryInfo, above, for info on 'baseFileName' and return types

def showbase.PythonUtil.choice | ( |  | condition,
|  |  | ifTrue,
|  |  | ifFalse
| ) |  |

def showbase.PythonUtil.clampScalar | ( |  | value,
|  |  | a,
|  |  | b
| ) |  |

def showbase.PythonUtil.closestDestAngle | ( |  | src,
|  |  | dest
| ) |  |

def showbase.PythonUtil.closestDestAngle2 | ( |  | src,
|  |  | dest
| ) |  |

def showbase.PythonUtil.configIsToday | ( |  | configName | ) |

def showbase.PythonUtil.contains | ( |  | whole,
|  |  | sub
| ) |  |

    Return 1 if whole contains sub, 0 otherwise

def showbase.PythonUtil.convertTree | ( |  | objTree,
|  |  | idList
| ) |  |

def showbase.PythonUtil.deeptype | ( |  | obj,
|  |  | maxLen = `100`,
|  |  | _visitedIds = `None`
| ) |  |

def showbase.PythonUtil.describeException | ( |  | backTrace = `4` | ) |

def showbase.PythonUtil.difference | ( |  | a,
|  |  | b
| ) |  |

    difference(list, list):

def showbase.PythonUtil.diffSinceBaseLine | ( |  | ) |

def showbase.PythonUtil.disjoint | ( |  | L1,
|  |  | L2
| ) |  |

    returns non-zero if L1 and L2 have no common elements

def showbase.PythonUtil.doc | ( |  | obj | ) |

def showbase.PythonUtil.encodedUtf8 | ( |  | s | ) |

def showbase.PythonUtil.endSuperLog | ( |  | ) |

def showbase.PythonUtil.enumerate | ( |  | L | ) |

    Returns (0, L[0]), (1, L[1]), etc., allowing this syntax:
    for i, item in enumerate(L):
       ...

    enumerate is a built-in feature in Python 2.3, which implements it
    using an iterator. For now, we can use this quick & dirty
    implementation that returns a list of tuples that is completely
    constructed every time enumerate() is called.

def showbase.PythonUtil.exceptionLogged | ( |  | append = `True` | ) |

    decorator that outputs the function name and all arguments
    if an exception passes back through the stack frame
    if append is true, string is appended to the __str__ output of
    the exception. if append is false, string is printed to the log
    directly. If the output will take up many lines, it's recommended
    to set append to False so that the exception stack is not hidden
    by the output of this decorator.

def showbase.PythonUtil.extractProfile | ( |  | args,
|  |  | kArgs
| ) |  |

def showbase.PythonUtil.fastRepr | ( |  | obj,
|  |  | maxLen = `200`,
|  |  | strFactor = `10`,
|  |  | _visitedIds = `None`
| ) |  |

    caps the length of iterable types, so very large objects will print faster.
    also prevents infinite recursion

def showbase.PythonUtil.findPythonModule | ( |  | module | ) |

def showbase.PythonUtil.fitDestAngle2Src | ( |  | src,
|  |  | dest
| ) |  |

    given a src and destination angle, returns an equivalent dest angle
    that is within [-180..180) of src
    examples:
    fitDestAngle2Src(30, 60) == 60
    fitDestAngle2Src(60, 30) == 30
    fitDestAngle2Src(0, 180) == -180
    fitDestAngle2Src(1, 180) == 180

def showbase.PythonUtil.fitSrcAngle2Dest | ( |  | src,
|  |  | dest
| ) |  |

    given a src and destination angle, returns an equivalent src angle
    that is within [-180..180) of dest
    examples:
    fitSrcAngle2Dest(30, 60) == 30
    fitSrcAngle2Dest(60, 30) == 60
    fitSrcAngle2Dest(0, 180) == 0
    fitSrcAngle2Dest(-1, 180) == 359
    fitSrcAngle2Dest(-180, 180) == 180

def showbase.PythonUtil.flywheel | ( |  | args,
|  |  | kArgs
| ) |  |

    >>> for i in flywheel([1,2,3], countList=[10, 5, 1]):
    ...   print i,
    ...
    1 2 3 1 2 1 2 1 2 1 2 1 1 1 1 1

def showbase.PythonUtil.formatElapsedSeconds | ( |  | seconds | ) |

    Returns a string of the form "mm:ss" or "hh:mm:ss" or "n days",
    representing the indicated elapsed time in seconds.

def showbase.PythonUtil.formatTimeCompact | ( |  | seconds | ) |

def showbase.PythonUtil.formatTimeExact | ( |  | seconds | ) |

def showbase.PythonUtil.get_all_objects | ( |  | ) |

    Return a list of all live Python
    objects, not including the list itself.

def showbase.PythonUtil.getAnnounceGenerateTime | ( |  | stat | ) |

def showbase.PythonUtil.getBase | ( |  | ) |

def showbase.PythonUtil.getClassLineage | ( |  | obj | ) |

    print object inheritance list

def showbase.PythonUtil.getIdList | ( |  | ) |

def showbase.PythonUtil.getNumberedTypedSortedString | ( |  | items,
|  |  | maxLen = `5000`,
|  |  | numPrefix = `''`
| ) |  |

    get a string that has each item of the list on its own line,
    the items are stringwise-sorted, and each item is numbered on
    the left from zero

def showbase.PythonUtil.getNumberedTypedSortedStringWithReferrers | ( |  | items,
|  |  | maxLen = `10000`,
|  |  | numPrefix = `''`
| ) |  |

    get a string that has each item of the list on its own line,
    the items are stringwise-sorted, the object's referrers are shown,
    and each item is numbered on the left from zero

def showbase.PythonUtil.getNumberedTypedSortedStringWithReferrersGen | ( |  | items,
|  |  | maxLen = `10000`,
|  |  | numPrefix = `''`
| ) |  |

    get a string that has each item of the list on its own line,
    the items are stringwise-sorted, the object's referrers are shown,
    and each item is numbered on the left from zero

def showbase.PythonUtil.getNumberedTypedString | ( |  | items,
|  |  | maxLen = `5000`,
|  |  | numPrefix = `''`
| ) |  |

    get a string that has each item of the list on its own line,
    and each item is numbered on the left from zero

def showbase.PythonUtil.getProfileResultString | ( |  | ) |

def showbase.PythonUtil.getRepository | ( |  | ) |

def showbase.PythonUtil.getSetter | ( |  | targetObj,
|  |  | valueName,
|  |  | prefix = `'set'`
| ) |  |

def showbase.PythonUtil.getSetterName | ( |  | valueName,
|  |  | prefix = `'set'`
| ) |  |

def showbase.PythonUtil.getShortestRotation | ( |  | start,
|  |  | end
| ) |  |

    Given two heading values, return a tuple describing
    the shortest interval from 'start' to 'end'.  This tuple
    can be used to lerp a camera between two rotations
    while avoiding the 'spin' problem.

def showbase.PythonUtil.getTotalAnnounceTime | ( |  | ) |

def showbase.PythonUtil.getTree | ( |  | obj | ) |

def showbase.PythonUtil.histogramDict | ( |  | l | ) |

def showbase.PythonUtil.indent | ( |  | stream,
|  |  | numIndents,
|  |  | str
| ) |  |

    Write str to stream with numIndents in front of it

def showbase.PythonUtil.intersection | ( |  | a,
|  |  | b
| ) |  |

    intersection(list, list):

def showbase.PythonUtil.invertDict | ( |  | D,
|  |  | lossy = `False`
| ) |  |

    creates a dictionary by 'inverting' D; keys are placed in the new
    dictionary under their corresponding value in the old dictionary.
    It is an error if D contains any duplicate values.

    >>> old = {'key1':1, 'key2':2}
    >>> invertDict(old)
    {1: 'key1', 2: 'key2'}

def showbase.PythonUtil.invertDictLossless | ( |  | D | ) |

    similar to invertDict, but values of new dict are lists of keys from
    old dict. No information is lost.

    >>> old = {'key1':1, 'key2':2, 'keyA':2}
    >>> invertDictLossless(old)
    {1: ['key1'], 2: ['key2', 'keyA']}

def showbase.PythonUtil.isDefaultValue | ( |  | x | ) |

def showbase.PythonUtil.isInteger | ( |  | n | ) |

def showbase.PythonUtil.itype | ( |  | obj | ) |

def showbase.PythonUtil.lerp | ( |  | v0,
|  |  | v1,
|  |  | t
| ) |  |

    returns a value lerped between v0 and v1, according to t
    t == 0 maps to v0, t == 1 maps to v1

def showbase.PythonUtil.lineage | ( |  | obj,
|  |  | verbose = `0`,
|  |  | indent = `0`
| ) |  |

    return instance or class name in as a multiline string.

    Usage: print lineage(foo)

    (Based on getClassLineage())

def showbase.PythonUtil.lineInfo | ( |  | baseFileName = `1` | ) |

    returns the sourcefilename, line number, and function name of the
    code that called this function
    (answers the question: 'hey lineInfo, where am I in the codebase?')
    see stackEntryInfo, above, for info on 'baseFileName' and return types

def showbase.PythonUtil.lineTag | ( |  | baseFileName = `1`,
|  |  | verbose = `0`,
|  |  | separator = `':'`
| ) |  |

    returns a string containing the sourcefilename and line number
    of the code that called this function
    (equivalent to lineInfo, above, with different return type)
    see stackEntryInfo, above, for info on 'baseFileName'

    if 'verbose' is false, returns a compact string of the form
    'fileName:lineNum:funcName'
    if 'verbose' is true, returns a longer string that matches the
    format of Python stack trace dumps

    returns empty string on error

def showbase.PythonUtil.lineupPos | ( |  | i,
|  |  | num,
|  |  | spacing
| ) |  |

    use to line up a series of 'num' objects, in one dimension,
    centered around zero
    'i' is the index of the object in the lineup
    'spacing' is the amount of space between objects in the lineup

def showbase.PythonUtil.list2dict | ( |  | L,
|  |  | value = `None`
| ) |  |

    creates dict using elements of list, all assigned to same value

def showbase.PythonUtil.listToIndex2item | ( |  | L | ) |

    converts list to dict of list index->list item

def showbase.PythonUtil.listToItem2index | ( |  | L | ) |

    converts list to dict of list item->list index
    This is lossy if there are duplicate list items

def showbase.PythonUtil.logBlock | ( |  | id,
|  |  | msg
| ) |  |

def showbase.PythonUtil.logMethodCalls | ( |  | cls | ) |

def showbase.PythonUtil.loopGen | ( |  | l | ) |

def showbase.PythonUtil.makeFlywheelGen | ( |  | objects,
|  |  | countList = `None`,
|  |  | countFunc = `None`,
|  |  | scale = `None`
| ) |  |

def showbase.PythonUtil.makeList | ( |  | x | ) |

    returns x, converted to a list

def showbase.PythonUtil.makeTuple | ( |  | x | ) |

    returns x, converted to a tuple

def showbase.PythonUtil.mostDerivedLast | ( |  | classList | ) |

    pass in list of classes. sorts list in-place, with derived classes
    appearing after their bases

def showbase.PythonUtil.nonRepeatingRandomList | ( |  | vals,
|  |  | max
| ) |  |

def showbase.PythonUtil.normalDistrib | ( |  | a,
|  |  | b,
|  |  | gauss = `random.gauss`
| ) |  |

    NOTE: assumes a < b

    Returns random number between a and b, using gaussian distribution, with
    mean=avg(a, b), and a standard deviation that fits ~99.7% of the curve
    between a and b.

    For ease of use, outlying results are re-computed until result is in [a, b]
    This should fit the remaining .3% of the curve that lies outside [a, b]
    uniformly onto the curve inside [a, b]

    ------------------------------------------------------------------------
    http://www-stat.stanford.edu/~naras/jsm/NormalDensity/NormalDensity.html

    The 68-95-99.7% Rule
    ====================
    All normal density curves satisfy the following property which is often
      referred to as the Empirical Rule:
    68% of the observations fall within 1 standard deviation of the mean.
    95% of the observations fall within 2 standard deviations of the mean.
    99.7% of the observations fall within 3 standard deviations of the mean.

    Thus, for a normal distribution, almost all values lie within 3 standard
      deviations of the mean.
    ------------------------------------------------------------------------

    In calculating our standard deviation, we divide (b-a) by 6, since the
    99.7% figure includes 3 standard deviations _on_either_side_ of the mean.

def showbase.PythonUtil.notNone | ( |  | A,
|  |  | B
| ) |  |

def showbase.PythonUtil.nullGen | ( |  | ) |

def showbase.PythonUtil.pandaBreak | ( |  | dotpath,
|  |  | linenum,
|  |  | temporary = `0`,
|  |  | cond = `None`
| ) |  |

def showbase.PythonUtil.pandaTrace | ( |  | ) |

def showbase.PythonUtil.pdir | ( |  | obj,
|  |  | str = `None`,
|  |  | width = `None`,
|  |  | fTruncate = `1`,
|  |  | lineWidth = `75`,
|  |  | wantPrivate = `0`
| ) |  |

def showbase.PythonUtil.pivotScalar | ( |  | scalar,
|  |  | pivot
| ) |  |

def showbase.PythonUtil.pretty_print | ( |  | tree | ) |

def showbase.PythonUtil.printListEnum | ( |  | l | ) |

def showbase.PythonUtil.printListEnumGen | ( |  | l | ) |

def showbase.PythonUtil.printNumberedTyped | ( |  | items,
|  |  | maxLen = `5000`
| ) |  |

    print out each item of the list on its own line,
    with each item numbered on the left from zero

def showbase.PythonUtil.printNumberedTypes | ( |  | items,
|  |  | maxLen = `5000`
| ) |  |

    print out the type of each item of the list on its own line,
    with each item numbered on the left from zero

def showbase.PythonUtil.printNumberedTypesGen | ( |  | items,
|  |  | maxLen = `5000`
| ) |  |

def showbase.PythonUtil.printProfile | ( |  | filename = `PyUtilProfileDefaultFilename`,
|  |  | lines = `PyUtilProfileDefaultLines`,
|  |  | sorts = `PyUtilProfileDefaultSorts`,
|  |  | callInfo = `1`
| ) |  |

def showbase.PythonUtil.printReverseStack | ( |  | ) |

def showbase.PythonUtil.printStack | ( |  | ) |

def showbase.PythonUtil.printThisCall | ( |  | ) |

def showbase.PythonUtil.printVerboseStack | ( |  | ) |

def showbase.PythonUtil.profiled | ( |  | category = `None`,
|  |  | terse = `False`
| ) |  |

    decorator for profiling functions
    turn categories on and off via "want-profile-categoryName 1"

    e.g.

    @profiled('particles')
    def loadParticles():
        ...

    want-profile-particles 1

def showbase.PythonUtil.profileFunc | ( |  | callback,
|  |  | name,
|  |  | terse,
|  |  | log = `True`
| ) |  |

def showbase.PythonUtil.pstatcollect | ( |  | scope,
|  |  | level = `None`
| ) |  |

def showbase.PythonUtil.quickProfile | ( |  | name = `"unnamed"` | ) |

def showbase.PythonUtil.r_add_chain | ( |  | objId,
|  |  | objList,
|  |  | objTree,
|  |  | idList,
|  |  | num
| ) |  |

def showbase.PythonUtil.r_convertTree | ( |  | oldTree,
|  |  | newTree,
|  |  | idList
| ) |  |

def showbase.PythonUtil.r_pretty_print | ( |  | tree,
|  |  | num
| ) |  |

def showbase.PythonUtil.randFloat | ( |  | a,
|  |  | b = `0.`,
|  |  | rng = `random.random`
| ) |  |

    returns a random float in [a, b]
    call with single argument to generate random float between arg and zero

def showbase.PythonUtil.randInt32 | ( |  | rng = `random.random` | ) |

    returns a random integer in [-2147483648..2147483647].
    rng must return float in [0..1]

def showbase.PythonUtil.randUint31 | ( |  | rng = `random.random` | ) |

    returns a random integer in [0..2^31).
    rng must return float in [0..1]

def showbase.PythonUtil.randUint32 | ( |  | rng = `random.random` | ) |

    returns a random integer in [0..2^32).
    rng must return float in [0..1]

def showbase.PythonUtil.recordCreationStack | ( |  | cls | ) |

def showbase.PythonUtil.recordCreationStackStr | ( |  | cls | ) |

def showbase.PythonUtil.recordFunctorCreationStacks | ( |  | ) |

def showbase.PythonUtil.reduceAngle | ( |  | deg | ) |

    Reduces an angle (in degrees) to a value in [-180..180)

def showbase.PythonUtil.repeatableRepr | ( |  | obj | ) |

def showbase.PythonUtil.replace | ( |  | list,
|  |  | old,
|  |  | new,
|  |  | all = `0`
| ) |  |

    replace 'old' with 'new' in 'list'
    if all == 0, replace first occurrence
    otherwise replace all occurrences
    returns the number of items replaced

def showbase.PythonUtil.report | ( |  | types = `[]`,
|  |  | prefix = `''`,
|  |  | xform = `None`,
|  |  | notifyFunc = `None`,
|  |  | dConfigParam = `[]`
| ) |  |

    This is a decorator generating function.  Use is similar to
    a @decorator, except you must be sure to call it as a function.
    It actually returns the decorator which is then used to transform
    your decorated function. Confusing at first, I know.

    Decoration occurs at function definition time.

    If __dev__ is not defined, or resolves to False, this function
    has no effect and no wrapping/transform occurs.  So in production,
    it's as if the report has been asserted out.

    Parameters::
    types : A subset list of ['timeStamp', 'frameCount', 'avLocation']
            This allows you to specify certain useful bits of info.

            module:     Prints the module that this report statement
                        can be found in.
            args:       Prints the arguments as they were passed to
                        this function.
            timeStamp:  Adds the current frame time to the output.
            deltaStamp: Adds the current AI synched frame time to
                        the output
            frameCount: Adds the current frame count to the output.
                        Usually cleaner than the timeStamp output.
            avLocation: Adds the localAvatar's network location
                        to the output.  Useful for interest debugging.
            interests:  Prints the current interest state after the
                        report.
            stackTrace: Prints a stack trace after the report.

    prefix: Optional string to prepend to output, just before the function.
            Allows for easy grepping and is useful when merging AI/Client
            reports into a single file.

    xform:  Optional callback that accepts a single parameter: argument 0 to
            the decorated function. (assumed to be 'self')
            It should return a value to be inserted into the report output string.

    notifyFunc: A notify function such as info, debug, warning, etc.
                By default the report will be printed to stdout. This
                will allow you send the report to a designated 'notify'
                output.

    dConfigParam: A list of Config.prc string variables.
                  By default the report will always print.  If you
                  specify this param, it will only print if one of the
                  specified config strings resolve to True.

def showbase.PythonUtil.safeRepr | ( |  | obj | ) |

def showbase.PythonUtil.safeReprTypeOnFail | ( |  | obj | ) |

def showbase.PythonUtil.safeTypeName | ( |  | o | ) |

def showbase.PythonUtil.sameElements | ( |  | a,
|  |  | b
| ) |  |

def showbase.PythonUtil.serialNum | ( |  | ) |

def showbase.PythonUtil.setupPdb | ( |  | ) |

def showbase.PythonUtil.solveQuadratic | ( |  | a,
|  |  | b,
|  |  | c
| ) |  |

def showbase.PythonUtil.stackEntryInfo | ( |  | depth = `0`,
|  |  | baseFileName = `1`
| ) |  |

    returns the sourcefilename, line number, and function name of
    an entry in the stack.
    'depth' is how far back to go in the stack; 0 is the caller of this
    function, 1 is the function that called the caller of this function, etc.
    by default, strips off the path of the filename; override with baseFileName
    returns (fileName, lineNum, funcName) --> (string, int, string)
    returns (None, None, None) on error

def showbase.PythonUtil.startProfile | ( |  | filename = `PyUtilProfileDefaultFilename`,
|  |  | lines = `PyUtilProfileDefaultLines`,
|  |  | sorts = `PyUtilProfileDefaultSorts`,
|  |  | silent = `0`,
|  |  | callInfo = `1`,
|  |  | useDisk = `False`,
|  |  | cmd = `'run()'`
| ) |  |

def showbase.PythonUtil.startSuperLog | ( |  | customFunction = `None` | ) |

def showbase.PythonUtil.str2elements | ( |  | str | ) |

def showbase.PythonUtil.tagRepr | ( |  | obj,
|  |  | tag
| ) |  |

    adds a string onto the repr output of an instance

def showbase.PythonUtil.tagWithCaller | ( |  | obj | ) |

    add info about the caller of the caller

def showbase.PythonUtil.testAlphabetCounter | ( |  | ) |

def showbase.PythonUtil.trace | ( |  | frame,
|  |  | event,
|  |  | arg
| ) |  |

def showbase.PythonUtil.traceFunctionCall | ( |  | frame | ) |

    return a string that shows the call frame with calling arguments.
    e.g.
    foo(x=234, y=135)

def showbase.PythonUtil.traceParentCall | ( |  | ) |

def showbase.PythonUtil.troff | ( |  | ) |

def showbase.PythonUtil.tron | ( |  | ) |

def showbase.PythonUtil.typeName | ( |  | o | ) |

def showbase.PythonUtil.u2ascii | ( |  | s | ) |

def showbase.PythonUtil.unescapeHtmlString | ( |  | s | ) |

def showbase.PythonUtil.unicodeUtf8 | ( |  | s | ) |

def showbase.PythonUtil.union | ( |  | a,
|  |  | b
| ) |  |

    union(list, list):

def showbase.PythonUtil.unique | ( |  | L1,
|  |  | L2
| ) |  |

    Return a list containing all items in 'L1' that are not in 'L2'

def showbase.PythonUtil.uniqueElements | ( |  | L | ) |

    are all elements of list unique?

def showbase.PythonUtil.uniqueName | ( |  | name | ) |

def showbase.PythonUtil.weightedChoice | ( |  | choiceList,
|  |  | rng = `random.random`,
|  |  | sum = `None`
| ) |  |

    given a list of (weight, item) pairs, chooses an item based on the
    weights. rng must return 0..1. if you happen to have the sum of the
    weights, pass it in 'sum'.

def showbase.PythonUtil.weightedRand | ( |  | valDict,
|  |  | rng = `random.random`
| ) |  |

    pass in a dictionary with a selection -> weight mapping.  Eg.
    {"Choice 1": 10,
     "Choice 2": 30,
     "bear":     100}

    -Weights need not add up to any particular value.
    -The actual selection will be returned.

def showbase.PythonUtil.writeFsmTree | ( |  | instance,
|  |  | indent = `0`
| ) |  |

## Variable Documentation

list __all__

int __report_indent = 3

_creationStackTrace

_creationStackTraceStrLst

int _KEY_DICT = 8

int _POS_LIST = 4

string _ProfileResultStr = ''

tuple _serialGen = SerialNumGen()

dictionary baseLine = {}

tuple bItem = pc.add(b)

tuple bpdb = BpDb.BpDb()

clamp = bound

dtoolSuperBase = None

enumerate = __builtin__.enumerate

exceptionLoggedNotify = None

tuple f = flywheel(['a','b','c','d'], countList=[11,20,3,4])

ftc = formatTimeCompact

fte = formatTimeExact

ftype = None

globalPdb = None

tuple GoldenRatio = (1. + math.sqrt(5.))

list l = []

list movedDumpFuncs = []

list movedLoadFuncs = []

list movedOpenFuncs = []

dictionary obj2count = {}

tuple p2 = PODtest()

dictionary packageMap

Initial value:

    00001 {
    00002     "toontown":"$TOONTOWN",
    00003     "direct":"$DIRECT",
    00004     "otp":"$OTP",
    00005     "pirates":"$PIRATES",
    00006 }

tuple pc = PriorityCallbacks()

dictionary profileFilename2file = {}

dictionary profileFilename2marshalData = {}

tuple profileFilenameList = Stack()

tuple profileFilenames = set()

string PyUtilProfileDefaultFilename = 'profiledata'

int PyUtilProfileDefaultLines = 80

list PyUtilProfileDefaultSorts = ['cumulative', 'time', 'calls']

tuple q = Queue()

rad180 = math.pi

float rad270 = 1.5

int rad360 = 2

int rad90 = 2

tuple s = ScratchPad()

safeReprNotify = None

tuple ScalarTypes = (types.FloatType, types.IntType, types.LongType)

superLogFile = None

traceCalled = False

All Classes Namespaces Functions Variables Enumerations Enumerator Properties