MCPcopy Index your code
hub / github.com/RustPython/RustPython / _splitlines_no_ff

Function _splitlines_no_ff

Lib/ast.py:319–335  ·  view source on GitHub ↗

Split a string into lines ignoring form feed and other chars. This mimics how the Python parser splits source code.

(source, maxlines=None)

Source from the content-addressed store, hash-verified

317
318_line_pattern = None
319def _splitlines_no_ff(source, maxlines=None):
320 """Split a string into lines ignoring form feed and other chars.
321
322 This mimics how the Python parser splits source code.
323 """
324 global _line_pattern
325 if _line_pattern is None:
326 # lazily computed to speedup import time of `ast`
327 import re
328 _line_pattern = re.compile(r"(.*?(?:\r\n|\n|\r|$))")
329
330 lines = []
331 for lineno, match in enumerate(_line_pattern.finditer(source), 1):
332 if maxlines is not None and lineno > maxlines:
333 break
334 lines.append(match[0])
335 return lines
336
337
338def _pad_whitespace(source):

Callers 1

get_source_segmentFunction · 0.85

Calls 4

enumerateFunction · 0.85
finditerMethod · 0.80
compileMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected