Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_self_merge_ref_substitutions_object3(self):
config1 = ConfigFactory.parse_string(
"""
b1 : { v1: 1 }
b = [${b1}]
""",
resolve=False
)
config2 = ConfigFactory.parse_string(
"""
b1 : { v1: 2, v2: 3 }
""",
resolve=False
)
merged = ConfigTree.merge_configs(config1, config2)
ConfigParser.resolve_substitutions(merged)
assert merged.get("b1") == {"v1": 2, "v2": 3}
b = merged.get("b")
assert len(b) == 1
assert b[0] == {"v1": 2, "v2": 3}
def __init__(self, config_tree=None):
if config_tree is None:
config_tree = ConfigTree()
self._config_tree = config_tree
self._namestack = []
def __init__(self, config_tree=None):
"""Create a Config.
Args:
config_tree (ConfigTree)
"""
if config_tree is None:
config_tree = ConfigTree()
self._config_tree = config_tree
def __getattr__(self, item):
val = self._config_tree[item]
if isinstance(val, ConfigTree):
return Config(val)
else:
return val
def get(self, key, default=None):
val = self._config_tree.get(key, default)
if isinstance(val, ConfigTree):
return Config(val)
else:
return val
def __getitem__(self, key):
try:
val = self._config_tree.get(self._full_key(key))
except ConfigMissingException:
raise KeyError(key)
if isinstance(val, ConfigTree):
return Metadata(val)
return val