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

Function arg_split

IPython/utils/_process_win32.py:176–206  ·  view source on GitHub ↗

Split a command line's arguments in a shell-like manner. This is a special version for windows that use a ctypes call to CommandLineToArgvW to do the argv splitting. The posix parameter is ignored. If strict=False, process_common.arg_split(...strict=False) is used instead.

(
        commandline: str, posix: bool = False, strict: bool = True
    )

Source from the content-addressed store, hash-verified

174 LocalFree.arg_types = [HLOCAL]
175
176 def arg_split(
177 commandline: str, posix: bool = False, strict: bool = True
178 ) -> List[str]:
179 """Split a command line's arguments in a shell-like manner.
180
181 This is a special version for windows that use a ctypes call to CommandLineToArgvW
182 to do the argv splitting. The posix parameter is ignored.
183
184 If strict=False, process_common.arg_split(...strict=False) is used instead.
185 """
186 # CommandLineToArgvW returns path to executable if called with empty string.
187 if commandline.strip() == "":
188 return []
189 if not strict:
190 # not really a cl-arg, fallback on _process_common
191 return py_arg_split(commandline, posix=posix, strict=strict)
192 argvn = c_int()
193 result_pointer = CommandLineToArgvW(commandline.lstrip(), ctypes.byref(argvn))
194 try:
195 result_array_type = LPCWSTR * argvn.value
196 result = [
197 arg
198 for arg in result_array_type.from_address(
199 ctypes.addressof(result_pointer.contents)
200 )
201 if arg is not None
202 ]
203 finally:
204 # for side effects
205 _ = LocalFree(result_pointer)
206 return result
207except AttributeError:
208 arg_split = py_arg_split
209

Callers 7

parse_argstringMethod · 0.90
file_matcherMethod · 0.90
shebangMethod · 0.90
test_arg_splitFunction · 0.90
test_arg_split_win32Function · 0.90
parse_optionsMethod · 0.50
magic_run_completerFunction · 0.50

Calls

no outgoing calls

Tested by 2

test_arg_splitFunction · 0.72
test_arg_split_win32Function · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…