in runtool/runtool/datatypes.py [0:0]
def as_dict(self) -> dict:
"""
Converts the DotDict into a python `dict` recursively.
>>> dotdict = DotDict({"a": {"b": {"c": [0, DotDict({"d": 1})]}}})
>>> type(dotdict)
<class 'runtool.datatypes.DotDict'>
>>> type(dotdict.a.b.c[1])
<class 'runtool.datatypes.DotDict'>
>>> as_dict = dotdict.as_dict()
>>> type(as_dict)
<class 'dict'>
>>> type(as_dict["a"]["b"]["c"][1])
<class 'dict'>
"""
def convert(value: Any) -> Any:
if isinstance(value, DotDict):
return value.as_dict()
elif isinstance(value, list):
return list(map(convert, value))
else:
return value
return {key: convert(value) for key, value in self.items()}