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

Method __call__

Lib/test/test_argparse.py:2284–2305  ·  view source on GitHub ↗
(self, parser, namespace, value, option_string=None)

Source from the content-addressed store, hash-verified

2282 class PositionalAction(argparse.Action):
2283
2284 def __call__(self, parser, namespace, value, option_string=None):
2285 try:
2286 assert option_string is None, ('option_string: %s' %
2287 option_string)
2288 # check destination
2289 assert self.dest == 'badger', 'dest: %s' % self.dest
2290 # when argument is before option, spam=0.25, and when
2291 # option is after argument, spam=<whatever was set>
2292 expected_ns = NS(badger=2)
2293 if value in [42, 84]:
2294 expected_ns.spam = 0.25
2295 elif value in [1]:
2296 expected_ns.spam = 0.625
2297 elif value in [2]:
2298 expected_ns.spam = 0.125
2299 else:
2300 raise AssertionError('value: %s' % value)
2301 assert expected_ns == namespace, ('expected %s, got %s' %
2302 (expected_ns, namespace))
2303 except AssertionError as e:
2304 raise ArgumentParserError('arg_action failed: %s' % e)
2305 setattr(namespace, 'badger', value)
2306
2307 argument_signatures = [
2308 Sig('-s', dest='spam', action=OptionalAction,

Callers

nothing calls this directly

Calls 2

ArgumentParserErrorClass · 0.85
NSClass · 0.70

Tested by

no test coverage detected