(self, action, arg_strings_pattern)
| 2470 | return [arg_line] |
| 2471 | |
| 2472 | def _match_argument(self, action, arg_strings_pattern): |
| 2473 | # match the pattern for this action to the arg strings |
| 2474 | nargs_pattern = self._get_nargs_pattern(action) |
| 2475 | match = _re.match(nargs_pattern, arg_strings_pattern) |
| 2476 | |
| 2477 | # raise an exception if we weren't able to find a match |
| 2478 | if match is None: |
| 2479 | nargs_errors = { |
| 2480 | None: _('expected one argument'), |
| 2481 | OPTIONAL: _('expected at most one argument'), |
| 2482 | ONE_OR_MORE: _('expected at least one argument'), |
| 2483 | } |
| 2484 | msg = nargs_errors.get(action.nargs) |
| 2485 | if msg is None: |
| 2486 | msg = ngettext('expected %s argument', |
| 2487 | 'expected %s arguments', |
| 2488 | action.nargs) % action.nargs |
| 2489 | raise ArgumentError(action, msg) |
| 2490 | |
| 2491 | # return the number of arguments matched |
| 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 |
nothing calls this directly
no test coverage detected