MCPcopy Index your code
hub / github.com/python/cpython / _match_arguments_partial

Method _match_arguments_partial

Lib/argparse.py:2494–2509  ·  view source on GitHub ↗
(self, actions, arg_strings_pattern)

Source from the content-addressed store, hash-verified

2492 return len(match.group(1))
2493
2494 def _match_arguments_partial(self, actions, arg_strings_pattern):
2495 # progressively shorten the actions list by slicing off the
2496 # final actions until we find a match
2497 for i in range(len(actions), 0, -1):
2498 actions_slice = actions[:i]
2499 pattern = ''.join([self._get_nargs_pattern(action)
2500 for action in actions_slice])
2501 match = _re.match(pattern, arg_strings_pattern)
2502 if match is not None:
2503 result = [len(string) for string in match.groups()]
2504 if (match.end() < len(arg_strings_pattern)
2505 and arg_strings_pattern[match.end()] == 'O'):
2506 while result and not result[-1]:
2507 del result[-1]
2508 return result
2509 return []
2510
2511 def _parse_optional(self, arg_string):
2512 # if it's an empty string, it was meant to be a positional

Callers

nothing calls this directly

Calls 5

_get_nargs_patternMethod · 0.95
joinMethod · 0.45
matchMethod · 0.45
groupsMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected