Skip to content
Snippets Groups Projects
Commit 17017e1a authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

MAINT(validator): make apply_schema_patches function private

parent 581f68bd
No related branches found
No related tags found
2 merge requests!217TST: Make NamedTemporaryFiles Windows-compatible,!201Validator that checks created records using a json schema
...@@ -71,7 +71,8 @@ def representer_ordereddict(dumper, data): ...@@ -71,7 +71,8 @@ def representer_ordereddict(dumper, data):
Helper function to be able to represent the converted json schema objects correctly as yaml. Helper function to be able to represent the converted json schema objects correctly as yaml.
This representer essentially replaced OrderedDict objects with simple dict objects. This representer essentially replaced OrderedDict objects with simple dict objects.
Since Python 3.7 dicts are ordered by default, see e.g.: https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/en/ Since Python 3.7 dicts are ordered by default, see e.g.:
https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/en/
Example how to use the representer: Example how to use the representer:
```python ```python
...@@ -81,7 +82,7 @@ def representer_ordereddict(dumper, data): ...@@ -81,7 +82,7 @@ def representer_ordereddict(dumper, data):
return dumper.represent_data(dict(data)) return dumper.represent_data(dict(data))
def apply_schema_patches(pobj: dict): def _apply_schema_patches(pobj: dict):
""" """
Changes applied: Changes applied:
- properties are moved vom subitem "proeprties" to top-level. - properties are moved vom subitem "proeprties" to top-level.
...@@ -92,7 +93,7 @@ def apply_schema_patches(pobj: dict): ...@@ -92,7 +93,7 @@ def apply_schema_patches(pobj: dict):
return pobj return pobj
for prop in pobj["properties"]: for prop in pobj["properties"]:
if isinstance(pobj["properties"][prop], dict): if isinstance(pobj["properties"][prop], dict):
pobj[prop] = apply_schema_patches(pobj["properties"][prop]) pobj[prop] = _apply_schema_patches(pobj["properties"][prop])
else: else:
pobj[prop] = pobj["properties"][prop] pobj[prop] = pobj["properties"][prop]
...@@ -108,8 +109,8 @@ def convert_record(record: db.Record): ...@@ -108,8 +109,8 @@ def convert_record(record: db.Record):
""" """
Convert a record into a form suitable for validation with jsonschema. Convert a record into a form suitable for validation with jsonschema.
Uses high_level_api.convert_to_python_object Uses `high_level_api.convert_to_python_object`
Afterwards apply_schema_patches is called recursively to refactor the dictionary Afterwards `_apply_schema_patches` is called recursively to refactor the dictionary
to match the current form of the jsonschema. to match the current form of the jsonschema.
Arguments: Arguments:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment