(self, action, arg_strings)
| 2207 | # Value conversion methods |
| 2208 | # ======================== |
| 2209 | def _get_values(self, action, arg_strings): |
| 2210 | # for everything but PARSER, REMAINDER args, strip out first '--' |
| 2211 | if action.nargs not in [PARSER, REMAINDER]: |
| 2212 | try: |
| 2213 | arg_strings.remove('--') |
| 2214 | except ValueError: |
| 2215 | pass |
| 2216 | |
| 2217 | # optional argument produces a default when not present |
| 2218 | if not arg_strings and action.nargs == OPTIONAL: |
| 2219 | if action.option_strings: |
| 2220 | value = action.const |
| 2221 | else: |
| 2222 | value = action.default |
| 2223 | if isinstance(value, basestring): |
| 2224 | value = self._get_value(action, value) |
| 2225 | self._check_value(action, value) |
| 2226 | |
| 2227 | # when nargs='*' on a positional, if there were no command-line |
| 2228 | # args, use the default if it is anything other than None |
| 2229 | elif (not arg_strings and action.nargs == ZERO_OR_MORE and |
| 2230 | not action.option_strings): |
| 2231 | if action.default is not None: |
| 2232 | value = action.default |
| 2233 | else: |
| 2234 | value = arg_strings |
| 2235 | self._check_value(action, value) |
| 2236 | |
| 2237 | # single argument or optional argument produces a single value |
| 2238 | elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]: |
| 2239 | arg_string, = arg_strings |
| 2240 | value = self._get_value(action, arg_string) |
| 2241 | self._check_value(action, value) |
| 2242 | |
| 2243 | # REMAINDER arguments convert all values, checking none |
| 2244 | elif action.nargs == REMAINDER: |
| 2245 | value = [self._get_value(action, v) for v in arg_strings] |
| 2246 | |
| 2247 | # PARSER arguments convert all values, but check only the first |
| 2248 | elif action.nargs == PARSER: |
| 2249 | value = [self._get_value(action, v) for v in arg_strings] |
| 2250 | self._check_value(action, value[0]) |
| 2251 | |
| 2252 | # all other types of nargs produce a list |
| 2253 | else: |
| 2254 | value = [self._get_value(action, v) for v in arg_strings] |
| 2255 | for v in value: |
| 2256 | self._check_value(action, v) |
| 2257 | |
| 2258 | # return the converted value |
| 2259 | return value |
| 2260 | |
| 2261 | def _get_value(self, action, arg_string): |
| 2262 | type_func = self._registry_get('type', action.type, action.type) |
no test coverage detected