MCPcopy Index your code
hub / github.com/ScrapeGraphAI/toonify / _parse_value

Function _parse_value

toon/decoder.py:425–459  ·  view source on GitHub ↗

Parse a single value string.

(value_str: str, opts: DecoderOptions)

Source from the content-addressed store, hash-verified

423
424
425def _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
462def _expand_paths(obj: dict) -> dict:

Callers 4

decodeFunction · 0.85
_parse_linesFunction · 0.85
_parse_tabular_arrayFunction · 0.85
_parse_list_arrayFunction · 0.85

Calls 3

unescape_stringFunction · 0.85
_split_rowFunction · 0.85
parse_literalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…