MCPcopy Index your code
hub / github.com/ipython/ipython / split_user_input

Function split_user_input

IPython/core/splitinput.py:43–68  ·  view source on GitHub ↗

Split user input into initial whitespace, escape character, function part and the rest.

(
    line: str, pattern: re.Pattern[str] | None = None
)

Source from the content-addressed store, hash-verified

41
42
43def split_user_input(
44 line: str, pattern: re.Pattern[str] | None = None
45) -> tuple[str, str, str, str]:
46 """Split user input into initial whitespace, escape character, function part
47 and the rest.
48 """
49 assert isinstance(line, str)
50
51 if pattern is None:
52 pattern = line_split
53 match = pattern.match(line)
54 if not match:
55 # print("match failed for line '%s'" % line)
56 try:
57 ifun, the_rest = line.split(None, 1)
58 except ValueError:
59 # print("split failed for line '%s'" % line)
60 ifun, the_rest = line, ""
61 pre = re.match(r"^(\s*)(.*)", line).groups()[0]
62 esc = ""
63 else:
64 pre, esc, ifun, the_rest = match.groups()
65
66 # print('line:<%s>' % line) # dbg
67 # print('pre <%s> ifun <%s> rest <%s>' % (pre,ifun.strip(),the_rest)) # dbg
68 return pre, esc or "", ifun.strip(), the_rest
69
70
71class LineInfo:

Callers 2

test_split_user_inputFunction · 0.90
__init__Method · 0.85

Calls 1

matchMethod · 0.80

Tested by 1

test_split_user_inputFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…