(self, parser, namespace, values, option_string=None)
| 1220 | return self._choices_actions |
| 1221 | |
| 1222 | def __call__(self, parser, namespace, values, option_string=None): |
| 1223 | parser_name = values[0] |
| 1224 | arg_strings = values[1:] |
| 1225 | |
| 1226 | # set the parser name if requested |
| 1227 | if self.dest is not SUPPRESS: |
| 1228 | setattr(namespace, self.dest, parser_name) |
| 1229 | |
| 1230 | # select the parser |
| 1231 | try: |
| 1232 | parser = self._name_parser_map[parser_name] |
| 1233 | except KeyError: |
| 1234 | args = {'parser_name': parser_name, |
| 1235 | 'choices': ', '.join(self._name_parser_map)} |
| 1236 | msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args |
| 1237 | raise ArgumentError(self, msg) |
| 1238 | |
| 1239 | # parse all the remaining options into the namespace |
| 1240 | # store any unrecognized options on the object, so that the top |
| 1241 | # level parser can decide what to do with them |
| 1242 | |
| 1243 | # In case this subparser defines new defaults, we parse them |
| 1244 | # in a new namespace object and then update the original |
| 1245 | # namespace for the relevant parts. |
| 1246 | subnamespace, arg_strings = parser.parse_known_args(arg_strings, None) |
| 1247 | for key, value in vars(subnamespace).items(): |
| 1248 | setattr(namespace, key, value) |
| 1249 | |
| 1250 | if arg_strings: |
| 1251 | vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, []) |
| 1252 | getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings) |
| 1253 | |
| 1254 | class _ExtendAction(_AppendAction): |
| 1255 | def __call__(self, parser, namespace, values, option_string=None): |
nothing calls this directly
no test coverage detected