MCPcopy Create free account
hub / github.com/numpy/numpy / isolate_expression

Function isolate_expression

tools/npy_tempita/__init__.py:1119–1132  ·  view source on GitHub ↗
(string, start_pos, end_pos)

Source from the content-addressed store, hash-verified

1117
1118
1119def isolate_expression(string, start_pos, end_pos):
1120 srow, scol = start_pos
1121 srow -= 1
1122 erow, ecol = end_pos
1123 erow -= 1
1124 lines = string.splitlines(True)
1125 if srow == erow:
1126 return lines[srow][scol:ecol]
1127 parts = [lines[srow][scol:]]
1128 parts.extend(lines[srow + 1:erow])
1129 if erow < len(lines):
1130 # It'll sometimes give (end_row_past_finish, 0)
1131 parts.append(lines[erow][:ecol])
1132 return ''.join(parts)
1133
1134_fill_command_usage = """\
1135%prog [OPTIONS] TEMPLATE arg=value

Callers 1

parse_signatureFunction · 0.85

Calls 2

splitlinesMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected