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

Function parse_multiline_str

Lib/tomllib/_parser.py:605–633  ·  view source on GitHub ↗
(src: str, pos: Pos, *, literal: bool)

Source from the content-addressed store, hash-verified

603
604
605def parse_multiline_str(src: str, pos: Pos, *, literal: bool) -> tuple[Pos, str]:
606 pos += 3
607 if src.startswith("\n", pos):
608 pos += 1
609
610 if literal:
611 delim = "'"
612 end_pos = skip_until(
613 src,
614 pos,
615 "'''",
616 error_on=ILLEGAL_MULTILINE_LITERAL_STR_CHARS,
617 error_on_eof=True,
618 )
619 result = src[pos:end_pos]
620 pos = end_pos + 3
621 else:
622 delim = '"'
623 pos, result = parse_basic_str(src, pos, multiline=True)
624
625 # Add at maximum two extra apostrophes/quotes if the end sequence
626 # is 4 or 5 chars long instead of just 3.
627 if not src.startswith(delim, pos):
628 return pos, result
629 pos += 1
630 if not src.startswith(delim, pos):
631 return pos, result + delim
632 pos += 1
633 return pos, result + (delim * 2)
634
635
636def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]:

Callers 1

parse_valueFunction · 0.85

Calls 3

skip_untilFunction · 0.85
parse_basic_strFunction · 0.85
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…