Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[a, b, c, d, e]
0 1, 2, 3, 4
case 1: move 1 to 3
[a, c, d, b, e]
0 1, 2, 3, 4
"""
key = self.get_index_change(path, key)
newkey = self.get_index_change(path, newkey)
if key == newkey:
return
new_op = MoveOperation({
'op': 'move',
'from': _path_join(path, key),
'path': _path_join(path, newkey),
})
self.insert(new_op)
self.add_index_change(path, key+1, -1)
self.add_index_change(path, newkey+1, +1)
def __init__(self, patch):
self.patch = patch
self.operations = {
'remove': RemoveOperation,
'add': AddOperation,
'replace': ReplaceOperation,
'move': MoveOperation,
'test': TestOperation,
'copy': CopyOperation,
}