StackFrame

class lsst.pex.config.callStack.StackFrame(filename, lineno, function, content=None)

Bases: object

A single element of the stack trace.

This differs slightly from the standard system mechanisms for getting a stack trace by the fact that it does not look up the source code until it is absolutely necessary, reducing the I/O.

Parameters:
filenamestr

Name of file containing the code being executed.

linenoint

Line number of file being executed.

functionstr

Function name being executed.

contentstr, optional

The actual content being executed. If not provided, it will be loaded from the file.

See also

getStackFrame

Notes

This differs slightly from the standard system mechanisms for getting a stack trace by the fact that it does not look up the source code until it is absolutely necessary, reducing the I/O.

Attributes Summary

content

Content being executed (loaded on demand) (str).

Methods Summary

format([full])

Format for printing.

fromFrame(frame)

Construct from a Frame object.

Attributes Documentation

content

Content being executed (loaded on demand) (str).

Methods Documentation

format(full=False)

Format for printing.

Parameters:
fullbool, optional

If True, output includes the conentent (StackFrame.content) being executed. Default is False.

Returns:
resultstr

Formatted string.

classmethod fromFrame(frame)

Construct from a Frame object.

Parameters:
frametypes.FrameType

Frame object to interpret, such as from inspect.currentframe.

Returns:
stackFrameStackFrame

A StackFrame instance.

Examples

inspect.currentframe provides a Frame object. This is a convenience constructor to interpret that Frame object:

>>> import inspect
>>> stackFrame = StackFrame.fromFrame(inspect.currentframe())