MCPcopy Index your code
hub / github.com/python/cpython / _splitlines_no_ff

Function _splitlines_no_ff

Lib/ast.py:333–349  ·  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

331
332_line_pattern = None
333def _splitlines_no_ff(source, maxlines=None):
334 """Split a string into lines ignoring form feed and other chars.
335
336 This mimics how the Python parser splits source code.
337 """
338 global _line_pattern
339 if _line_pattern is None:
340 # lazily computed to speedup import time of `ast`
341 import re
342 _line_pattern = re.compile(r"(.*?(?:\r\n|\n|\r|$))")
343
344 lines = []
345 for lineno, match in enumerate(_line_pattern.finditer(source), 1):
346 if maxlines is not None and lineno > maxlines:
347 break
348 lines.append(match[0])
349 return lines
350
351
352def _pad_whitespace(source):

Callers 1

get_source_segmentFunction · 0.85

Calls 3

enumerateFunction · 0.85
compileMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…