MCPcopy Index your code
hub / github.com/RustPython/RustPython / __call__

Method __call__

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

Source from the content-addressed store, hash-verified

1284 return self._choices_actions
1285
1286 def __call__(self, parser, namespace, values, option_string=None):
1287 parser_name = values[0]
1288 arg_strings = values[1:]
1289
1290 # set the parser name if requested
1291 if self.dest is not SUPPRESS:
1292 setattr(namespace, self.dest, parser_name)
1293
1294 # select the parser
1295 try:
1296 subparser = self._name_parser_map[parser_name]
1297 except KeyError:
1298 args = {'parser_name': parser_name,
1299 'choices': ', '.join(self._name_parser_map)}
1300 msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args
1301 raise ArgumentError(self, msg)
1302
1303 if parser_name in self._deprecated:
1304 parser._warning(_("command '%(parser_name)s' is deprecated") %
1305 {'parser_name': parser_name})
1306
1307 # parse all the remaining options into the namespace
1308 # store any unrecognized options on the object, so that the top
1309 # level parser can decide what to do with them
1310
1311 # In case this subparser defines new defaults, we parse them
1312 # in a new namespace object and then update the original
1313 # namespace for the relevant parts.
1314 subnamespace, arg_strings = subparser.parse_known_args(arg_strings, None)
1315 for key, value in vars(subnamespace).items():
1316 setattr(namespace, key, value)
1317
1318 if arg_strings:
1319 if not hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
1320 setattr(namespace, _UNRECOGNIZED_ARGS_ATTR, [])
1321 getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
1322
1323class _ExtendAction(_AppendAction):
1324 def __call__(self, parser, namespace, values, option_string=None):

Callers

nothing calls this directly

Calls 11

setattrFunction · 0.85
varsFunction · 0.85
hasattrFunction · 0.85
getattrFunction · 0.85
_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