Resolve a dotted path like ``steps.specify.output.file`` against *obj*. Supports dict key access and list indexing (e.g., ``task_list[0]``).
(obj: Any, path: str)
| 95 | |
| 96 | |
| 97 | def _resolve_dot_path(obj: Any, path: str) -> Any: |
| 98 | """Resolve a dotted path like ``steps.specify.output.file`` against *obj*. |
| 99 | |
| 100 | Supports dict key access and list indexing (e.g., ``task_list[0]``). |
| 101 | """ |
| 102 | parts = path.split(".") |
| 103 | current = obj |
| 104 | for part in parts: |
| 105 | # Handle list indexing: name[0] |
| 106 | idx_match = re.match(r"^([\w-]+)\[(\d+)\]$", part) |
| 107 | if idx_match: |
| 108 | key, idx = idx_match.group(1), int(idx_match.group(2)) |
| 109 | if isinstance(current, dict): |
| 110 | current = current.get(key) |
| 111 | else: |
| 112 | return None |
| 113 | if isinstance(current, list) and 0 <= idx < len(current): |
| 114 | current = current[idx] |
| 115 | else: |
| 116 | return None |
| 117 | elif isinstance(current, dict): |
| 118 | current = current.get(part) |
| 119 | else: |
| 120 | return None |
| 121 | if current is None: |
| 122 | return None |
| 123 | return current |
| 124 | |
| 125 | |
| 126 | def _build_namespace(context: Any) -> dict[str, Any]: |
no test coverage detected