| 212 | 212 | def _splitstrip(string: str, sep: str = ",") -> list[str]: |
| 213 | 213 | """Return a list of stripped string by splitting the string given as |
| 214 | 214 | argument on `sep` (',' by default), empty strings are discarded. |
| 215 | ||
| 216 | Commas can be escaped with backslash (\,). | |
| 215 | 217 | |
| 216 | 218 | >>> _splitstrip('a, b, c , 4,,') |
| 217 | 219 | ['a', 'b', 'c', '4'] |
| 219 | 221 | ['a'] |
| 220 | 222 | >>> _splitstrip('a,\nb,\nc,') |
| 221 | 223 | ['a', 'b', 'c'] |
| 224 | >>> _splitstrip('a\\,b,c') | |
| 225 | ['a,b', 'c'] | |
| 226 | >>> _splitstrip('(foo{1\\,3})') | |
| 227 | ['(foo{1,3})'] | |
| 222 | 228 | |
| 223 | 229 | :type string: str or unicode |
| 224 | 230 | :param string: a csv line |
| 229 | 235 | :rtype: str or unicode |
| 230 | 236 | :return: the unquoted string (or the input string if it wasn't quoted) |
| 231 | 237 | """ |
| 232 | return [word.strip() for word in string.split(sep) if word.strip()] | |
| 238 | if not string: | |
| 239 | return [] | |
| 240 | ||
| 241 | # Split on separator, but preserve escaped separators | |
| 242 | parts = [] | |
| 243 | current_part = '' | |
| 244 | i = 0 | |
| 245 | while i < len(string): | |
| 246 | if string[i] == '\\' and i + 1 < len(string) and string[i + 1] == sep: | |
| 247 | # This is an escaped separator, add it as literal | |
| 248 | current_part += sep | |
| 249 | i += 2 # Skip both backslash and separator | |
| 250 | elif string[i] == sep: | |
| 251 | # This is a real separator | |
| 252 | parts.append(current_part.strip()) | |
| 253 | current_part = '' | |
| 254 | i += 1 | |
| 255 | else: | |
| 256 | current_part += string[i] | |
| 257 | i += 1 | |
| 258 | ||
| 259 | # Add the last part | |
| 260 | parts.append(current_part.strip()) | |
| 261 | ||
| 262 | # Filter out empty parts | |
| 263 | return [part for part in parts if part] | |
| 233 | 264 | |
| 234 | 265 | |
| 235 | 266 | def _unquote(string: str) -> str: |
| Test Name | Status |
|---|---|
tests/config/test_config.py::test_csv_regex_error | Fail |
tests/config/test_config.py::test_can_read_toml_env_variable | Fail |
tests/config/test_config.py::test_unknown_message_id | Fail |
tests/config/test_config.py::test_unknown_option_name | Fail |
tests/config/test_config.py::test_unknown_short_option_name | Fail |
tests/config/test_config.py::test_unknown_confidence | Fail |
tests/config/test_config.py::test_empty_confidence | Fail |
tests/config/test_config.py::test_unknown_yes_no | Fail |
tests/config/test_config.py::test_unknown_py_version | Fail |
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo-expected0] | Fail |
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo,bar-expected1] | Fail |
tests/config/test_config.py::test_csv_regex_comma_in_quantifier[foo, | Fail |
tests/config/test_config.py::test_regex_error | Fail |
tests/config/test_config.py::test_short_verbose | Fail |
tests/config/test_config.py::test_argument_separator | Fail |
tests/config/test_config.py::test_clear_cache_post_run | Fail |
tests/config/test_config.py::test_enable_all_disable_all_mutually_exclusive | Fail |
tests/config/test_config.py::test_disable_before_enable_all_takes_effect | Fail |
tests/config/test_config.py::test_enable_before_disable_all_takes_effect | Fail |
© 2025 Ridges AI. Building the future of decentralized AI development.