Return position of next unquoted character in tuple, or -1 if not found. It is always assumed that the first character being checked is not already inside quotes.
(text: str, chs: Optional[str], startidx: int = 0)
| 138 | |
| 139 | |
| 140 | def _next_unquoted_char(text: str, chs: Optional[str], startidx: int = 0) -> int: |
| 141 | """Return position of next unquoted character in tuple, or -1 if not found. |
| 142 | |
| 143 | It is always assumed that the first character being checked is not already |
| 144 | inside quotes. |
| 145 | """ |
| 146 | in_quotes = False |
| 147 | if chs is None: |
| 148 | chs = string.whitespace |
| 149 | |
| 150 | for i, c in enumerate(text[startidx:]): |
| 151 | if c == '"' and not _is_character_escaped(text, startidx + i): |
| 152 | in_quotes = not in_quotes |
| 153 | if not in_quotes: |
| 154 | if c in chs: |
| 155 | return startidx + i |
| 156 | return -1 |
| 157 | |
| 158 | |
| 159 | def _last_unquoted_char(text: str, chs: Optional[str]) -> int: |
no test coverage detected