Given a frame object, returns the total number of lines in the file containing the frame's code object, or the number of lines in the frame's source code if the file is not available. Parameters ---------- frame : FrameType The frame object whose line number is to b
(frame: types.FrameType)
| 39 | |
| 40 | |
| 41 | def get_line_number_of_frame(frame: types.FrameType) -> int: |
| 42 | """ |
| 43 | Given a frame object, returns the total number of lines in the file |
| 44 | containing the frame's code object, or the number of lines in the |
| 45 | frame's source code if the file is not available. |
| 46 | |
| 47 | Parameters |
| 48 | ---------- |
| 49 | frame : FrameType |
| 50 | The frame object whose line number is to be determined. |
| 51 | |
| 52 | Returns |
| 53 | ------- |
| 54 | int |
| 55 | The total number of lines in the file containing the frame's |
| 56 | code object, or the number of lines in the frame's source code |
| 57 | if the file is not available. |
| 58 | """ |
| 59 | filename = frame.f_code.co_filename |
| 60 | if filename is None: |
| 61 | print("No file....") |
| 62 | lines, first = inspect.getsourcelines(frame) |
| 63 | return first + len(lines) |
| 64 | return count_lines_in_py_file(filename) |
| 65 | |
| 66 | |
| 67 | def _safe_string(value: Any, what: Any, func: Any = str) -> str: |
no test coverage detected
searching dependent graphs…