Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_path(patch):
"""Return the path for a given dictdiffer.diff patch."""
if patch[1] != '':
keys = (patch[1].split('.') if isinstance(patch[1], string_types)
else patch[1])
else:
keys = []
keys = keys + [patch[2][0][0]] if patch[0] != 'change' else keys
return tuple(keys)
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
if all(map(lambda x: isinstance(x, string_types), node)):
return '.'.join(node)