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

Method _get_option_tuples

Lib/argparse.py:2475–2517  ·  view source on GitHub ↗
(self, option_string)

Source from the content-addressed store, hash-verified

2473 return [(None, arg_string, None, None)]
2474
2475 def _get_option_tuples(self, option_string):
2476 result = []
2477
2478 # option strings starting with two prefix characters are only
2479 # split at the '='
2480 chars = self.prefix_chars
2481 if option_string[0] in chars and option_string[1] in chars:
2482 if self.allow_abbrev:
2483 option_prefix, sep, explicit_arg = option_string.partition('=')
2484 if not sep:
2485 sep = explicit_arg = None
2486 for option_string in self._option_string_actions:
2487 if option_string.startswith(option_prefix):
2488 action = self._option_string_actions[option_string]
2489 tup = action, option_string, sep, explicit_arg
2490 result.append(tup)
2491
2492 # single character options can be concatenated with their arguments
2493 # but multiple character options always have to have their argument
2494 # separate
2495 elif option_string[0] in chars and option_string[1] not in chars:
2496 option_prefix, sep, explicit_arg = option_string.partition('=')
2497 if not sep:
2498 sep = explicit_arg = None
2499 short_option_prefix = option_string[:2]
2500 short_explicit_arg = option_string[2:]
2501
2502 for option_string in self._option_string_actions:
2503 if option_string == short_option_prefix:
2504 action = self._option_string_actions[option_string]
2505 tup = action, option_string, '', short_explicit_arg
2506 result.append(tup)
2507 elif self.allow_abbrev and option_string.startswith(option_prefix):
2508 action = self._option_string_actions[option_string]
2509 tup = action, option_string, sep, explicit_arg
2510 result.append(tup)
2511
2512 # shouldn't ever get here
2513 else:
2514 raise ArgumentError(None, _('unexpected option string: %s') % option_string)
2515
2516 # return the collected option tuples
2517 return result
2518
2519 def _get_nargs_pattern(self, action):
2520 # in all examples below, we have to allow for '--' args

Callers 1

_parse_optionalMethod · 0.95

Calls 5

ArgumentErrorClass · 0.70
_Function · 0.50
partitionMethod · 0.45
startswithMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected