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

Method _get_values

Lib/argparse.py:2597–2642  ·  view source on GitHub ↗
(self, action, arg_strings)

Source from the content-addressed store, hash-verified

2595 # ========================
2596
2597 def _get_values(self, action, arg_strings):
2598 # optional argument produces a default when not present
2599 if not arg_strings and action.nargs == OPTIONAL:
2600 if action.option_strings:
2601 value = action.const
2602 else:
2603 value = action.default
2604 if isinstance(value, str) and value is not SUPPRESS:
2605 value = self._get_value(action, value)
2606
2607 # when nargs='*' on a positional, if there were no command-line
2608 # args, use the default if it is anything other than None
2609 elif (not arg_strings and action.nargs == ZERO_OR_MORE and
2610 not action.option_strings):
2611 if action.default is not None:
2612 value = action.default
2613 else:
2614 value = []
2615
2616 # single argument or optional argument produces a single value
2617 elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
2618 arg_string, = arg_strings
2619 value = self._get_value(action, arg_string)
2620 self._check_value(action, value)
2621
2622 # REMAINDER arguments convert all values, checking none
2623 elif action.nargs == REMAINDER:
2624 value = [self._get_value(action, v) for v in arg_strings]
2625
2626 # PARSER arguments convert all values, but check only the first
2627 elif action.nargs == PARSER:
2628 value = [self._get_value(action, v) for v in arg_strings]
2629 self._check_value(action, value[0])
2630
2631 # SUPPRESS argument does not put anything in the namespace
2632 elif action.nargs == SUPPRESS:
2633 value = SUPPRESS
2634
2635 # all other types of nargs produce a list
2636 else:
2637 value = [self._get_value(action, v) for v in arg_strings]
2638 for v in value:
2639 self._check_value(action, v)
2640
2641 # return the converted value
2642 return value
2643
2644 def _get_value(self, action, arg_string):
2645 type_func = self._registry_get('type', action.type, action.type)

Callers 1

take_actionMethod · 0.95

Calls 4

_get_valueMethod · 0.95
_check_valueMethod · 0.95
isinstanceFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected