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

Method _read_args_from_files

Lib/argparse.py:2360–2385  ·  view source on GitHub ↗
(self, arg_strings)

Source from the content-addressed store, hash-verified

2358 return namespace, extras
2359
2360 def _read_args_from_files(self, arg_strings):
2361 # expand arguments referencing files
2362 new_arg_strings = []
2363 for arg_string in arg_strings:
2364
2365 # for regular arguments, just add them back into the list
2366 if not arg_string or arg_string[0] not in self.fromfile_prefix_chars:
2367 new_arg_strings.append(arg_string)
2368
2369 # replace arguments referencing files with the file content
2370 else:
2371 try:
2372 with open(arg_string[1:],
2373 encoding=_sys.getfilesystemencoding(),
2374 errors=_sys.getfilesystemencodeerrors()) as args_file:
2375 arg_strings = []
2376 for arg_line in args_file.read().splitlines():
2377 for arg in self.convert_arg_line_to_args(arg_line):
2378 arg_strings.append(arg)
2379 arg_strings = self._read_args_from_files(arg_strings)
2380 new_arg_strings.extend(arg_strings)
2381 except OSError as err:
2382 raise ArgumentError(None, str(err))
2383
2384 # return the modified argument list
2385 return new_arg_strings
2386
2387 def convert_arg_line_to_args(self, arg_line):
2388 return [arg_line]

Callers 1

_parse_known_argsMethod · 0.95

Calls 8

strFunction · 0.85
openFunction · 0.70
ArgumentErrorClass · 0.70
appendMethod · 0.45
splitlinesMethod · 0.45
readMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected