| 2119 | return None, arg_string, None |
| 2120 | |
| 2121 | def _get_option_tuples(self, option_string): |
| 2122 | result = [] |
| 2123 | |
| 2124 | # option strings starting with two prefix characters are only |
| 2125 | # split at the '=' |
| 2126 | chars = self.prefix_chars |
| 2127 | if option_string[0] in chars and option_string[1] in chars: |
| 2128 | if '=' in option_string: |
| 2129 | option_prefix, explicit_arg = option_string.split('=', 1) |
| 2130 | else: |
| 2131 | option_prefix = option_string |
| 2132 | explicit_arg = None |
| 2133 | for option_string in self._option_string_actions: |
| 2134 | if option_string.startswith(option_prefix): |
| 2135 | action = self._option_string_actions[option_string] |
| 2136 | tup = action, option_string, explicit_arg |
| 2137 | result.append(tup) |
| 2138 | |
| 2139 | # single character options can be concatenated with their arguments |
| 2140 | # but multiple character options always have to have their argument |
| 2141 | # separate |
| 2142 | elif option_string[0] in chars and option_string[1] not in chars: |
| 2143 | option_prefix = option_string |
| 2144 | explicit_arg = None |
| 2145 | short_option_prefix = option_string[:2] |
| 2146 | short_explicit_arg = option_string[2:] |
| 2147 | |
| 2148 | for option_string in self._option_string_actions: |
| 2149 | if option_string == short_option_prefix: |
| 2150 | action = self._option_string_actions[option_string] |
| 2151 | tup = action, option_string, short_explicit_arg |
| 2152 | result.append(tup) |
| 2153 | elif option_string.startswith(option_prefix): |
| 2154 | action = self._option_string_actions[option_string] |
| 2155 | tup = action, option_string, explicit_arg |
| 2156 | result.append(tup) |
| 2157 | |
| 2158 | # shouldn't ever get here |
| 2159 | else: |
| 2160 | self.error(_('unexpected option string: %s') % option_string) |
| 2161 | |
| 2162 | # return the collected option tuples |
| 2163 | return result |
| 2164 | |
| 2165 | def _get_nargs_pattern(self, action): |
| 2166 | # in all examples below, we have to allow for '--' args |