recursive obj subsetting#97
Merged
2 commits merged intodevelopfrom Feb 8, 2022
Merged
Conversation
ghost
commented
Feb 8, 2022
ghost
commented
Feb 8, 2022
ghost
commented
Feb 8, 2022
| try: | ||
| conf = service_conf[name] | ||
| auth = (_CONF["db_user"], _CONF["db_pass"]) | ||
| print("auth is", auth) |
ghost
commented
Feb 8, 2022
Comment on lines
+231
to
+249
| def is_obj_subset_rec( | ||
| l: Union[dict, list, float, str, int], | ||
| r: Union[dict, list, float, str, int], | ||
| ): | ||
| """ | ||
| Compare two JSON objects, to see if, essentially, l <= r | ||
| If comparing dicts, recursively compare | ||
| If comparing lists, shallowly compare. For now, YAGN more | ||
| """ | ||
| if isinstance(l, dict) and isinstance(r, dict): | ||
| return all( | ||
| [k in r.keys() and is_obj_subset_rec(l[k], r[k]) for k in l.keys()] | ||
| ) # ignore: typing | ||
| elif isinstance(l, list) and isinstance(r, list): | ||
| return all([le in r for le in l]) | ||
| else: | ||
| return l == r # noqa: E741 | ||
|
|
||
|
|
Author
There was a problem hiding this comment.
My first guess on how to compare the local/server specs was just local.items() <= server.items() with the assumption that ArangoDB would only add default parameters. Kind of worked, but ended up working better with recursive subset checks ..
ialarmedalien
requested changes
Feb 8, 2022
Collaborator
ialarmedalien
left a comment
There was a problem hiding this comment.
Just add a comment about checking the develop branch rather than master
This pull request was closed.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For changes to the codebase: