23 __all__ = [
'getCallerFrame',
'getStackFrame',
'StackFrame',
'getCallStack']
30 """Retrieve the frame for the caller 32 By "caller", we mean our user's caller. 36 relative : `int`, non-negative 37 Number of frames above the caller to retrieve. 41 frame : `__builtin__.Frame` 44 frame = inspect.currentframe().f_back.f_back
45 for ii
in range(relative):
51 """Retrieve the stack frame for the caller 53 By "caller", we mean our user's caller. 57 relative : `int`, non-negative 58 Number of frames 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 73 getting a stack trace by the fact that it does not look up the 74 source code until it 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` or `None` 85 The actual content being executed. If not provided, it will be 88 _STRIP =
"/python/lsst/" 90 def __init__(self, filename, lineno, function, content=None):
91 loc = filename.rfind(self.
_STRIP)
93 filename = filename[loc + len(self.
_STRIP):]
101 """Getter for content being executed 103 Load from file on demand. 111 """Construct from a Frame object 113 inspect.currentframe() provides a Frame object. This is 114 a convenience constructor to interpret that Frame object. 119 Frame object to interpret. 123 output : `StackFrame` 126 filename = frame.f_code.co_filename
127 lineno = frame.f_lineno
128 function = frame.f_code.co_name
129 return cls(filename, lineno, function)
135 """Format for printing 140 Print full details, including content being executed? 149 result +=
"\n %s" % (self.
content,)
154 """Retrieve the call stack for the caller 156 By "caller", we mean our user's caller - we don't include ourselves 159 The result is ordered with the most recent frame last. 163 skip : `int`, non-negative 164 Number of stack frames above caller to skip. 168 output : `list` of `StackFrame` 174 stack.append(StackFrame.fromFrame(frame))
176 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)