Set a value in the dictionary. :param path: The path, e.g. foo.bar.baz :param value: The value
(self, path: str, value: Any)
| 73 | return |
| 74 | |
| 75 | def set(self, path: str, value: Any) -> None: |
| 76 | """ |
| 77 | Set a value in the dictionary. |
| 78 | |
| 79 | :param path: The path, e.g. foo.bar.baz |
| 80 | :param value: The value |
| 81 | """ |
| 82 | current = self._d |
| 83 | keys = path.split('.') |
| 84 | for i in range(len(keys) - 1): |
| 85 | key = keys[i] |
| 86 | next_current = current.get(key) |
| 87 | if not isinstance(next_current, dict): |
| 88 | next_current = {} |
| 89 | current[key] = next_current |
| 90 | current = next_current |
| 91 | current[keys[-1]] = value |
| 92 | |
| 93 | def remove(self, path: str) -> None: |
| 94 | """ |