MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / lookup_lines

Function lookup_lines

aura/utils.py:153–175  ·  view source on GitHub ↗
(
        pth: str,
        line_nos: List[int],
        strip: bool=True,
        encoding: str="utf-8"
)

Source from the content-addressed store, hash-verified

151
152
153def lookup_lines(
154 pth: str,
155 line_nos: List[int],
156 strip: bool=True,
157 encoding: str="utf-8"
158) -> Mapping[int, str]:
159 line_nos = sorted(line_nos)
160 lines = {}
161 if not line_nos:
162 return lines
163
164 with codecs.open(pth, "r", encoding=encoding) as fd:
165 for ix, line in enumerate(fd):
166 if ix > line_nos[-1] + 1:
167 break
168
169 line_no = ix + 1
170
171 if line_no in line_nos:
172 if strip:
173 line = line.strip()
174 lines[line_no] = line
175 return lines
176
177
178def set_function_attr(**kwargs):

Callers 1

post_analysisMethod · 0.85

Calls 1

stripMethod · 0.80

Tested by

no test coverage detected