Split on top-level commas (respecting parens and quotes).
(s: str)
| 120 | # ────────────────────────────────────────────────────────────────────────────── |
| 121 | |
| 122 | def _split_specifiers(s: str) -> list: |
| 123 | """Split on top-level commas (respecting parens and quotes).""" |
| 124 | parts = [] |
| 125 | depth = 0 |
| 126 | in_quote = False |
| 127 | quote_char = None |
| 128 | current = [] |
| 129 | for ch in s: |
| 130 | if in_quote: |
| 131 | current.append(ch) |
| 132 | if ch == quote_char: |
| 133 | in_quote = False |
| 134 | elif ch in ('"', "'"): |
| 135 | in_quote = True |
| 136 | quote_char = ch |
| 137 | current.append(ch) |
| 138 | elif ch == '(': |
| 139 | depth += 1 |
| 140 | current.append(ch) |
| 141 | elif ch == ')': |
| 142 | depth -= 1 |
| 143 | current.append(ch) |
| 144 | elif ch == ',' and depth == 0: |
| 145 | parts.append(''.join(current)) |
| 146 | current = [] |
| 147 | else: |
| 148 | current.append(ch) |
| 149 | if current: |
| 150 | parts.append(''.join(current)) |
| 151 | return parts |
| 152 | |
| 153 | def _parse_specifiers(args: str) -> dict: |
| 154 | result = {} |
no outgoing calls
no test coverage detected