-
Notifications
You must be signed in to change notification settings - Fork 10
recursive obj subsetting #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
|
|
||
| def match(spec_local, specs_server): | ||
| for spec_server in specs_server: | ||
| if spec_local.items() <= spec_server.items(): | ||
| if is_obj_subset_rec(spec_local, spec_server): | ||
| return True | ||
| return False | ||
|
|
||
|
|
@@ -228,6 +228,25 @@ def excise_namespace(analyzer_name: str) -> str: | |
| return analyzer_name.split("::")[-1] | ||
|
|
||
|
|
||
| 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 | ||
|
|
||
|
|
||
|
Comment on lines
+231
to
+249
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My first guess on how to compare the local/server specs was just |
||
| def mod_obj_literal( | ||
| spec_unit: Union[list, dict], | ||
| literal_type: type, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,6 @@ def wait_for_service(service_list: List[str]) -> None: | |
| try: | ||
| conf = service_conf[name] | ||
| auth = (_CONF["db_user"], _CONF["db_pass"]) | ||
| print("auth is", auth) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was showing up in logs |
||
| resp = requests.get(conf["url"], auth=auth) | ||
| if conf.get("raise_for_status"): | ||
| resp.raise_for_status() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.