From 17017e1a59d97a003e773fa01cb7b2d117ad26b4 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Fri, 29 Nov 2024 09:15:27 +0100 Subject: [PATCH] MAINT(validator): make apply_schema_patches function private --- src/caoscrawler/validator.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/caoscrawler/validator.py b/src/caoscrawler/validator.py index 3051f4c4..fdfed23f 100644 --- a/src/caoscrawler/validator.py +++ b/src/caoscrawler/validator.py @@ -71,7 +71,8 @@ def representer_ordereddict(dumper, data): 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. - 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: ```python @@ -81,7 +82,7 @@ def representer_ordereddict(dumper, data): return dumper.represent_data(dict(data)) -def apply_schema_patches(pobj: dict): +def _apply_schema_patches(pobj: dict): """ Changes applied: - properties are moved vom subitem "proeprties" to top-level. @@ -92,7 +93,7 @@ def apply_schema_patches(pobj: dict): return pobj for prop in pobj["properties"]: if isinstance(pobj["properties"][prop], dict): - pobj[prop] = apply_schema_patches(pobj["properties"][prop]) + pobj[prop] = _apply_schema_patches(pobj["properties"][prop]) else: pobj[prop] = pobj["properties"][prop] @@ -108,8 +109,8 @@ def convert_record(record: db.Record): """ Convert a record into a form suitable for validation with jsonschema. - Uses high_level_api.convert_to_python_object - Afterwards apply_schema_patches is called recursively to refactor the dictionary + Uses `high_level_api.convert_to_python_object` + Afterwards `_apply_schema_patches` is called recursively to refactor the dictionary to match the current form of the jsonschema. Arguments: -- GitLab