| 2410 | return len(match.group(1)) |
| 2411 | |
| 2412 | def _match_arguments_partial(self, actions, arg_strings_pattern): |
| 2413 | # progressively shorten the actions list by slicing off the |
| 2414 | # final actions until we find a match |
| 2415 | for i in range(len(actions), 0, -1): |
| 2416 | actions_slice = actions[:i] |
| 2417 | pattern = ''.join([self._get_nargs_pattern(action) |
| 2418 | for action in actions_slice]) |
| 2419 | match = _re.match(pattern, arg_strings_pattern) |
| 2420 | if match is not None: |
| 2421 | result = [len(string) for string in match.groups()] |
| 2422 | if (match.end() < len(arg_strings_pattern) |
| 2423 | and arg_strings_pattern[match.end()] == 'O'): |
| 2424 | while result and not result[-1]: |
| 2425 | del result[-1] |
| 2426 | return result |
| 2427 | return [] |
| 2428 | |
| 2429 | def _parse_optional(self, arg_string): |
| 2430 | # if it's an empty string, it was meant to be a positional |