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)
| 222 | |
| 223 | |
| 224 | def 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 | |
| 246 | def stack_multi_slice(drop_functions : List[Tuple[str, int]] = [], |
| 247 | end_functions : List[str] = ["<module>"], |
no test coverage detected