MCPcopy Create free account
hub / github.com/libgit2/pygit2 / for_line

Method for_line

pygit2/blame.py:140–157  ·  view source on GitHub ↗

Returns the object for a given line given its number in the current Blame. Parameters: line_no Line number, starts at 1.

(self, line_no: int)

Source from the content-addressed store, hash-verified

138 return BlameHunk._from_c(self, chunk)
139
140 def for_line(self, line_no: int) -> BlameHunk:
141 """
142 Returns the <BlameHunk> object for a given line given its number in the
143 current Blame.
144
145 Parameters:
146
147 line_no
148 Line number, starts at 1.
149 """
150 if line_no < 0:
151 raise IndexError
152
153 chunk = C.git_blame_get_hunk_byline(self._blame, line_no)
154 if not chunk:
155 raise IndexError
156
157 return BlameHunk._from_c(self, chunk)
158
159 def __iter__(self) -> Iterator[BlameHunk]:
160 return GenericIterator(self)

Callers 2

test_blame_for_lineFunction · 0.80

Calls 1

_from_cMethod · 0.45

Tested by 2

test_blame_for_lineFunction · 0.64