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

Function split_by_unquoted

numpy/f2py/crackfortran.py:668–686  ·  view source on GitHub ↗

Splits the line into (line[:i], line[i:]), where i is the index of first occurrence of one of the characters not within quotes, or len(line) if no such index exists

(line, characters)

Source from the content-addressed store, hash-verified

666##
667
668def split_by_unquoted(line, characters):
669 """
670 Splits the line into (line[:i], line[i:]),
671 where i is the index of first occurrence of one of the characters
672 not within quotes, or len(line) if no such index exists
673 """
674 assert not (set('"\'') & set(characters)), "cannot split by unquoted quotes"
675 r = re.compile(
676 r"\A(?P<before>({single_quoted}|{double_quoted}|{not_quoted})*)"
677 r"(?P<after>{char}.*)\Z".format(
678 not_quoted="[^\"&#x27;{}]".format(re.escape(characters)),
679 char="[{}]".format(re.escape(characters)),
680 single_quoted=r"('([^'\\]|(\\.))*')",
681 double_quoted=r'("([^"\\]|(\\.))*")'))
682 m = r.match(line)
683 if m:
684 d = m.groupdict()
685 return (d["before"], d["after"])
686 return (line, "")
687
688def _simplifyargs(argsline):
689 a = []

Callers 3

readfortrancodeFunction · 0.85
cracklineFunction · 0.85
markoutercommaFunction · 0.85

Calls 1

compileMethod · 0.45

Tested by

no test coverage detected