MCPcopy Create free account
hub / github.com/bterwijn/memory_graph / stack_slice

Function stack_slice

memory_graph/__init__.py:224–244  ·  view source on GitHub ↗

Returns a slice of the call stack. Parameters: begin_functions - list of (function-name, offset), begins at the index of the first 'function-name' that is found in the call stack with additional 'offset', otherwise begins at index 0

(begin_functions : List[Tuple[str, int]] = [],
                end_functions : List[str] = ["<module>"],
                stack_index : int = 0,
                frameInfos : List[inspect.FrameInfo] = None)

Source from the content-addressed store, hash-verified

222
223
224def stack_slice(begin_functions : List[Tuple[str, int]] = [],
225 end_functions : List[str] = ["<module>"],
226 stack_index : int = 0,
227 frameInfos : List[inspect.FrameInfo] = None):
228 """
229 Returns a slice of the call stack.
230 Parameters:
231 begin_functions - list of (function-name, offset), begins at the index of the first
232 'function-name' that is found in the call stack with additional 'offset',
233 otherwise begins at index 0
234 end_functions - list of function-names, ends at the index of the first 'function-name'
235 that is found in the call stack after begin index (inclusive),
236 otherwise ends at the last index
237 stack_index - number of frames removed from the beginning
238 """
239 if frameInfos == None:
240 frameInfos = inspect.stack()
241 stack_functions = [s.function for s in frameInfos]
242 begin_index = stack_begin_index(stack_functions, begin_functions)
243 end_index = stack_end_index(stack_functions, begin_index, end_functions)
244 return stack_frames_to_dict(reversed(frameInfos[begin_index+stack_index:end_index+1]))
245
246def stack_multi_slice(drop_functions : List[Tuple[str, int]] = [],
247 end_functions : List[str] = ["<module>"],

Callers 6

stackFunction · 0.85
stack_pdbFunction · 0.85
stack_vscodeFunction · 0.85
stack_cursorFunction · 0.85
stack_pycharmFunction · 0.85
stack_wingFunction · 0.85

Calls 3

stack_begin_indexFunction · 0.85
stack_end_indexFunction · 0.85
stack_frames_to_dictFunction · 0.85

Tested by

no test coverage detected