23 __all__ = [
'getCallerFrame',
'getStackFrame',
'StackFrame',
'getCallStack']
30 """Get the frame for the user's caller. 34 relative : `int`, optional 35 Number of frames (0 or more) above the caller to retrieve. Default is 0. 39 frame : `__builtin__.Frame` 44 This function is excluded from the frame. 46 frame = inspect.currentframe().f_back.f_back
47 for ii
in range(relative):
53 """Get the `StackFrame` for the user's caller. 57 relative : `int`, optional 58 Number of frames (0 or more) above the caller to retrieve. 63 Stack frame for the caller. 66 return StackFrame.fromFrame(frame)
70 """A single element of the stack trace. 72 This differs slightly from the standard system mechanisms for getting a 73 stack trace by the fact that it does not look up the source code until it 74 is absolutely necessary, reducing the I/O. 79 Name of file containing the code being executed. 81 Line number of file being executed. 83 Function name being executed. 84 content : `str`, optional 85 The actual content being executed. If not provided, it will be loaded 90 This differs slightly from the standard system mechanisms for getting a 91 stack trace by the fact that it does not look up the source code until it 92 is absolutely necessary, reducing the I/O. 99 _STRIP =
"/python/lsst/" 100 """String to strip from the ``filename`` in the constructor.""" 102 def __init__(self, filename, lineno, function, content=None):
103 loc = filename.rfind(self.
_STRIP)
105 filename = filename[loc + len(self.
_STRIP):]
113 """Content being executed (loaded on demand) (`str`). 121 """Construct from a Frame object. 126 Frame object to interpret, such as from `inspect.currentframe`. 130 stackFrame : `StackFrame` 131 A `StackFrame` instance. 135 `inspect.currentframe` provides a Frame object. This is a convenience 136 constructor to interpret that Frame object: 139 >>> stackFrame = StackFrame.fromFrame(inspect.currentframe()) 141 filename = frame.f_code.co_filename
142 lineno = frame.f_lineno
143 function = frame.f_code.co_name
144 return cls(filename, lineno, function)
150 """Format for printing. 154 full : `bool`, optional 155 If `True`, output includes the conentent (`StackFrame.content`) being executed. Default 165 result +=
"\n %s" % (self.
content,)
170 """Retrieve the call stack for the caller. 174 skip : `int`, non-negative 175 Number of stack frames above caller to skip. 179 output : `list` of `StackFrame` 180 The call stack. The `list` is ordered with the most recent frame to 185 This function is excluded from the call stack. 190 stack.append(StackFrame.fromFrame(frame))
192 return list(reversed(stack))
def __init__(self, filename, lineno, function, content=None)
def fromFrame(cls, frame)
def getStackFrame(relative=0)
def getCallerFrame(relative=0)
def format(self, full=False)
daf::base::PropertyList * list