-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #639 from vidartf/cellid-diff
Add support for using cell ID in diffing and merging
- Loading branch information
Showing
56 changed files
with
1,113 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
class DiffConfig: | ||
"""Set of predicates/differs/other configs to pass around""" | ||
|
||
def __init__(self, *, predicates=None, differs=None, atomic_paths=None): | ||
if predicates is None: | ||
from .generic import default_predicates | ||
predicates = default_predicates() | ||
|
||
if differs is None: | ||
from .generic import default_differs | ||
differs = default_differs() | ||
|
||
self.predicates = predicates | ||
self.differs = differs | ||
self._atomic_paths = atomic_paths or {} | ||
|
||
def diff_item_at_path(self, a, b, path): | ||
"""Calculate the diff for path.""" | ||
self.differs[path](a, b, path=path, config=self) | ||
|
||
def is_atomic(self, x, path=None): | ||
"Return True for values that diff should treat as a single atomic value." | ||
try: | ||
return self._atomic_paths[path] | ||
except KeyError: | ||
return not isinstance(x, (str, list, dict)) | ||
|
||
def __copy__(self): | ||
return DiffConfig( | ||
predicates=self.predicates.copy(), | ||
differs=self.differs.copy(), | ||
atomic_paths=self._atomic_paths.copy(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.