schrodinger.models.diffy module

Need a diff in a jiffy? Use diffy!

schrodinger.models.diffy.get_diff(new_state, old_state)

Given two states of an object, calculate what changed between them.

schrodinger.models.diffy.get_removed(new_state, old_state)
schrodinger.models.diffy.get_added(new_state, old_state)
schrodinger.models.diffy.get_updated(new_state, old_state)
schrodinger.models.diffy.get_moved(new_state, old_state)
class schrodinger.models.diffy.ListDiff(added, removed, moved)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

added

Alias for field number 0

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

moved

Alias for field number 2

removed

Alias for field number 1

schrodinger.models.diffy.get_diff_list(new_state, old_state)

Calculate what was added, removed, and moved between two states of a list.

Note that items are compared by identity not equality (ie is rather than ==).

Returns:A namedtuple describing what was added, removed, and moved between two lists. See get_added, get_removed, and get_moved more details.
Return type:ListDiff(set, set, set)
class schrodinger.models.diffy.SetDiff(added, removed)

Bases: tuple

__contains__

Return key in self.

__init__

Initialize self. See help(type(self)) for accurate signature.

__len__

Return len(self).

added

Alias for field number 0

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

removed

Alias for field number 1

schrodinger.models.diffy.get_diff_set(new_state, old_state)

Calculate what was added and removed between two states of a set.

Returns:A namedtuple describing what was added and removed.
Return type:SetDiff(set, set)
schrodinger.models.diffy.get_removed_set(new_state, old_state)

Calculate what was removed between two states of a set.

Return type:set
schrodinger.models.diffy.get_removed_list(new_state, old_state)
Returns:A set of tuples, each describing an item that was removed and and its index in old_state
Return type:set((object, int))
schrodinger.models.diffy.get_added_list(new_state, old_state)
Returns:A set of tuples, each describing an item that was added and and its index in new_state.
Return type:set((object, int))
schrodinger.models.diffy.get_added_set(new_state, old_state)

Calculate what was removed between two states of a set.

Return type:set
schrodinger.models.diffy.get_added_dict(new_state, old_state)
Returns:A dictionary with items in new_state but not in old_state.
schrodinger.models.diffy.get_moved_list(new_state, old_state)
Returns:A set of tuples, each describing an item that was moved and and its index in new_state
Return type:set((object, int))