MCPcopy
hub / github.com/Textualize/rich / _iter_syntax_lines

Function _iter_syntax_lines

rich/traceback.py:56–81  ·  view source on GitHub ↗

Yield start and end positions per line. Args: start: Start position. end: End position. Returns: Iterable of (LINE, COLUMN1, COLUMN2).

(
    start: SyntaxPosition, end: SyntaxPosition
)

Source from the content-addressed store, hash-verified

54
55
56def _iter_syntax_lines(
57 start: SyntaxPosition, end: SyntaxPosition
58) -> Iterable[Tuple[int, int, int]]:
59 """Yield start and end positions per line.
60
61 Args:
62 start: Start position.
63 end: End position.
64
65 Returns:
66 Iterable of (LINE, COLUMN1, COLUMN2).
67 """
68
69 line1, column1 = start
70 line2, column2 = end
71
72 if line1 == line2:
73 yield line1, column1, column2
74 else:
75 for first, last, line_no in loop_first_last(range(line1, line2 + 1)):
76 if first:
77 yield line_no, column1, -1
78 elif last:
79 yield line_no, 0, column2
80 else:
81 yield line_no, 0, -1
82
83
84def install(

Callers 1

_render_stackMethod · 0.85

Calls 1

loop_first_lastFunction · 0.85

Tested by

no test coverage detected