MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / _expand_paths

Function _expand_paths

toon/decoder.py:462–501  ·  view source on GitHub ↗

Expand dotted paths into nested objects. Args: obj: Object with potentially dotted keys Returns: Expanded object

(obj: dict)

Source from the content-addressed store, hash-verified

460
461
462def _expand_paths(obj: dict) -> dict:
463 """
464 Expand dotted paths into nested objects.
465
466 Args:
467 obj: Object with potentially dotted keys
468
469 Returns:
470 Expanded object
471 """
472 result = {}
473
474 for key, value in obj.items():
475 if '.' in key:
476 # Split path and create nested structure
477 parts = key.split('.')
478 current = result
479
480 for i, part in enumerate(parts[:-1]):
481 if part not in current:
482 current[part] = {}
483 elif not isinstance(current[part], dict):
484 # Conflict - keep original
485 result[key] = value
486 break
487 current = current[part]
488 else:
489 # Set final value
490 current[parts[-1]] = value
491 else:
492 result[key] = value
493
494 # Recursively expand nested objects
495 for key, value in result.items():
496 if isinstance(value, dict):
497 result[key] = _expand_paths(value)
498 elif isinstance(value, list):
499 result[key] = [_expand_paths(item) if isinstance(item, dict) else item for item in value]
500
501 return result

Callers 1

decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…