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_dot_lookup(self):
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b'), 'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ['a', 'b']),
'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b', parent=True),
{'b': 'hello'})
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ''),
{'a': {'b': 'hello'}})
def test_dot_lookup(self):
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b'), 'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ['a', 'b']),
'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b', parent=True),
{'b': 'hello'})
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ''),
{'a': {'b': 'hello'}})
def test_dot_lookup(self):
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b'), 'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ['a', 'b']),
'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b', parent=True),
{'b': 'hello'})
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ''),
{'a': {'b': 'hello'}})
def test_dot_lookup(self):
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b'), 'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ['a', 'b']),
'hello')
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, 'a.b', parent=True),
{'b': 'hello'})
self.assertEqual(dot_lookup({'a': {'b': 'hello'}}, ''),
{'a': {'b': 'hello'}})
def change(node, changes):
dest = dot_lookup(destination, node, parent=True)
if isinstance(node, string_types):
last_node = node.split('.')[-1]
else:
last_node = node[-1]
if isinstance(dest, LIST_TYPES):
last_node = int(last_node)
_, value = changes
dest[last_node] = value
def remove(node, changes):
for key, value in changes:
dest = dot_lookup(destination, node)
if isinstance(dest, SET_TYPES):
dest -= value
else:
del dest[key]
def add(node, changes):
for key, value in changes:
dest = dot_lookup(destination, node)
if isinstance(dest, LIST_TYPES):
dest.insert(key, value)
elif isinstance(dest, SET_TYPES):
dest |= value
else:
dest[key] = value