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

Method __call__

Lib/argparse.py:1362–1397  ·  view source on GitHub ↗
(self, parser, namespace, values, option_string=None)

Source from the content-addressed store, hash-verified

1360 return self._choices_actions
1361
1362 def __call__(self, parser, namespace, values, option_string=None):
1363 parser_name = values[0]
1364 arg_strings = values[1:]
1365
1366 # set the parser name if requested
1367 if self.dest is not SUPPRESS:
1368 setattr(namespace, self.dest, parser_name)
1369
1370 # select the parser
1371 try:
1372 subparser = self._name_parser_map[parser_name]
1373 except KeyError:
1374 args = {'parser_name': parser_name,
1375 'choices': ', '.join(self._name_parser_map)}
1376 msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args
1377 raise ArgumentError(self, msg)
1378
1379 if parser_name in self._deprecated:
1380 parser._warning(_("command '%(parser_name)s' is deprecated") %
1381 {'parser_name': parser_name})
1382
1383 # parse all the remaining options into the namespace
1384 # store any unrecognized options on the object, so that the top
1385 # level parser can decide what to do with them
1386
1387 # In case this subparser defines new defaults, we parse them
1388 # in a new namespace object and then update the original
1389 # namespace for the relevant parts.
1390 subnamespace, arg_strings = subparser.parse_known_args(arg_strings, None)
1391 for key, value in vars(subnamespace).items():
1392 setattr(namespace, key, value)
1393
1394 if arg_strings:
1395 if not hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
1396 setattr(namespace, _UNRECOGNIZED_ARGS_ATTR, [])
1397 getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
1398
1399class _ExtendAction(_AppendAction):
1400 def __call__(self, parser, namespace, values, option_string=None):

Callers

nothing calls this directly

Calls 7

_warningMethod · 0.80
parse_known_argsMethod · 0.80
ArgumentErrorClass · 0.70
_Function · 0.50
joinMethod · 0.45
itemsMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected