MCPcopy Create free account
hub / github.com/RustPython/RustPython / consume_positionals

Method consume_positionals

Lib/argparse.py:2225–2254  ·  view source on GitHub ↗
(start_index)

Source from the content-addressed store, hash-verified

2223
2224 # function to convert arg_strings into positional actions
2225 def consume_positionals(start_index):
2226 # match as many Positionals as possible
2227 match_partial = self._match_arguments_partial
2228 selected_pattern = arg_strings_pattern[start_index:]
2229 arg_counts = match_partial(positionals, selected_pattern)
2230
2231 # slice off the appropriate arg strings for each Positional
2232 # and add the Positional and its args to the list
2233 for action, arg_count in zip(positionals, arg_counts):
2234 args = arg_strings[start_index: start_index + arg_count]
2235 # Strip out the first '--' if it is not in REMAINDER arg.
2236 if action.nargs == PARSER:
2237 if arg_strings_pattern[start_index] == '-':
2238 assert args[0] == '--'
2239 args.remove('--')
2240 elif action.nargs != REMAINDER:
2241 if (arg_strings_pattern.find('-', start_index,
2242 start_index + arg_count) >= 0):
2243 args.remove('--')
2244 start_index += arg_count
2245 if args and action.deprecated and action.dest not in warned:
2246 self._warning(_("argument '%(argument_name)s' is deprecated") %
2247 {'argument_name': action.dest})
2248 warned.add(action.dest)
2249 take_action(action, args)
2250
2251 # slice off the Positionals that we just parsed and return the
2252 # index at which the Positionals' string args stopped
2253 positionals[:] = positionals[len(arg_counts):]
2254 return start_index
2255
2256 # consume Positionals and Optionals alternately, until we have
2257 # passed the last option string

Callers

nothing calls this directly

Calls 6

_warningMethod · 0.95
lenFunction · 0.85
_Function · 0.50
removeMethod · 0.45
findMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected