Parse a single value string.
(value_str: str, opts: DecoderOptions)
| 423 | |
| 424 | |
| 425 | def _parse_value(value_str: str, opts: DecoderOptions) -> Any: |
| 426 | """Parse a single value string.""" |
| 427 | value_str = value_str.strip() |
| 428 | |
| 429 | if not value_str: |
| 430 | return None |
| 431 | |
| 432 | # Check for quoted string |
| 433 | if value_str.startswith(QUOTE) and value_str.endswith(QUOTE) and len(value_str) >= 2: |
| 434 | # Unquote and unescape |
| 435 | inner = value_str[1:-1] |
| 436 | return unescape_string(inner) |
| 437 | |
| 438 | # Check for inline array [val1,val2,...] |
| 439 | if value_str.startswith(LEFT_BRACKET) and value_str.endswith(RIGHT_BRACKET): |
| 440 | inner = value_str[1:-1] |
| 441 | if not inner: |
| 442 | return [] |
| 443 | |
| 444 | # Detect delimiter |
| 445 | delimiter = COMMA |
| 446 | if TAB in inner: |
| 447 | delimiter = TAB |
| 448 | elif PIPE in inner: |
| 449 | delimiter = PIPE |
| 450 | |
| 451 | values = _split_row(inner, delimiter) |
| 452 | return [_parse_value(v.strip(), opts) for v in values] |
| 453 | |
| 454 | # Check for empty object |
| 455 | if value_str == '{}': |
| 456 | return {} |
| 457 | |
| 458 | # Parse as literal (bool, null, number, or string) |
| 459 | return parse_literal(value_str) |
| 460 | |
| 461 | |
| 462 | def _expand_paths(obj: dict) -> dict: |
no test coverage detected
searching dependent graphs…