| 14 | dict-like container that allows for attribute-based access to keys. |
| 15 | """ |
| 16 | def __init__(self, init_dict=None, key_list=None, new_allowed=False): |
| 17 | # Recursively convert nested dictionaries in init_dict into CfgNodes |
| 18 | init_dict = {} if init_dict is None else init_dict |
| 19 | key_list = [] if key_list is None else key_list |
| 20 | for k, v in init_dict.items(): |
| 21 | if type(v) is dict: |
| 22 | # Convert dict to CfgNode |
| 23 | init_dict[k] = CfgNode(v, key_list=key_list + [k]) |
| 24 | super(CfgNode, self).__init__(init_dict) |
| 25 | |
| 26 | def __getattr__(self, name): |
| 27 | if name in self: |