How to use the dictdiffer.revert function in dictdiffer

To help you get started, we’ve selected a few dictdiffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inveniosoftware / dictdiffer / tests / test_dictdiffer.py View on Github external
def test_list_of_different_length(self):
        """Check that one can revert list with different length."""
        first = [1]
        second = [1, 2, 3]
        result = list(diff(first, second))
        assert first == revert(result, second)
github Mirantis / solar / solar / system_log / change.py View on Github external
def _revert_remove(logitem):
    """Resource should be created with all previous connections
    """
    commited = CommitedResource.get(logitem.resource)
    args = dictdiffer.revert(logitem.diff, commited.inputs)
    connections = dictdiffer.revert(logitem.connections_diff, sorted(commited.connections))

    resource.Resource(logitem.resource, logitem.base_path,
        args=_get_args_to_update(args, connections), tags=commited.tags)
    for emitter, emitter_input, receiver, receiver_input in connections:
        emmiter_obj = resource.load(emitter)
        receiver_obj = resource.load(receiver)
        signals.connect(emmiter_obj, receiver_obj, {emitter_input: receiver_input})
github Mirantis / solar / solar / system_log / change.py View on Github external
def _discard_update(item):
    resource_obj = resource.load(item.resource)
    old_connections = resource_obj.connections
    new_connections = dictdiffer.revert(item.connections_diff, sorted(old_connections))
    args = dictdiffer.revert(item.diff, resource_obj.args)

    _update_inputs_connections(
        resource_obj, _get_args_to_update(args, new_connections), old_connections, new_connections)
github Mirantis / solar / solar / system_log / change.py View on Github external
def _discard_update(item):
    resource_obj = resource.load(item.resource)
    old_connections = resource_obj.connections
    new_connections = dictdiffer.revert(item.connections_diff, sorted(old_connections))
    args = dictdiffer.revert(item.diff, resource_obj.args)

    _update_inputs_connections(
        resource_obj, _get_args_to_update(args, new_connections), old_connections, new_connections)
github Mirantis / solar / solar / system_log / change.py View on Github external
def _revert_update(logitem):
    """Revert of update should update inputs and connections
    """
    res_obj = resource.load(logitem.resource)
    commited = res_obj.load_commited()

    connections = dictdiffer.revert(logitem.connections_diff, sorted(commited.connections))
    args = dictdiffer.revert(logitem.diff, commited.inputs)

    _update_inputs_connections(
        res_obj, _get_args_to_update(args, connections), commited.connections, connections)
github Mirantis / solar / solar / system_log / change.py View on Github external
def _revert_remove(logitem):
    """Resource should be created with all previous connections
    """
    commited = CommitedResource.get(logitem.resource)
    args = dictdiffer.revert(logitem.diff, commited.inputs)
    connections = dictdiffer.revert(logitem.connections_diff, sorted(commited.connections))

    resource.Resource(logitem.resource, logitem.base_path,
        args=_get_args_to_update(args, connections), tags=commited.tags)
    for emitter, emitter_input, receiver, receiver_input in connections:
        emmiter_obj = resource.load(emitter)
        receiver_obj = resource.load(receiver)
        signals.connect(emmiter_obj, receiver_obj, {emitter_input: receiver_input})