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

Function parse_multiline_str

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

Source from the content-addressed store, hash-verified

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