mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-11 01:28:17 +03:00
11 lines
431 B
Python
11 lines
431 B
Python
from dataclasses import replace
|
|
from typing import Any
|
|
|
|
|
|
def recursive_replace(root_obj: Any, replace_str: str, replace_with: Any) -> Any:
|
|
split_str = replace_str.split(".")
|
|
if len(split_str) == 1:
|
|
return replace(root_obj, **{split_str[0]: replace_with})
|
|
sub_obj = recursive_replace(getattr(root_obj, split_str[0]), ".".join(split_str[1:]), replace_with)
|
|
return replace(root_obj, **{split_str[0]: sub_obj})
|