jsonschema_diff.core¶
Submodules¶
Classes¶
Package Contents¶
- class Statuses(*args, **kwds)[source]¶
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- ADDED = '+'¶
- DELETED = '-'¶
- REPLACED = 'r'¶
- MODIFIED = 'm'¶
- NO_DIFF = ' '¶
- UNKNOWN = '?'¶
- class Compare(
- config: jsonschema_diff.core.config.Config,
- schema_path: COMPARE_PATH_TYPE,
- json_path: COMPARE_PATH_TYPE,
- to_compare: list[ToCompare],
- status¶
- config¶
- schema_path¶
- json_path¶
- to_compare¶
- calc_diff() dict[str, int][source]¶
Basic implementation: counts its own status as 1 element. Complex comparators (e.g. CompareList) override this to return an aggregate.
- class CompareCombined(*args: Any, **kwargs: Any)[source]¶
-
- calc_diff() dict[str, int][source]¶
Multiple implementation: counts its own status as the number of keys. Complex comparators (e.g. CompareList) override this to return an aggregate.
- class Config(
- tab: str = ' ',
- all_for_rendering: bool = False,
- crop_path: bool = True,
- compare_rules: jsonschema_diff.core.tools.compare.COMPARE_RULES_TYPE = {},
- combine_rules: jsonschema_diff.core.tools.combine.COMBINE_RULES_TYPE = [],
- path_maker_ignore: jsonschema_diff.core.tools.render.PATH_MAKER_IGNORE_RULES_TYPE = ['properties', 'items'],
- pair_context_rules: jsonschema_diff.core.tools.context.PAIR_CONTEXT_RULES_TYPE = [],
- context_rules: jsonschema_diff.core.tools.context.CONTEXT_RULES_TYPE = {},
- compare_config: COMPARE_CONFIG_TYPE = {},
- property_key_groups: PROPERTY_KEY_GROUPS_TYPE = {dict: ['properties', '$defs'], list: ['prefixItems', 'items']},
-
- ALL_FOR_RENDERING = False¶
- CROP_PATH = True¶
- COMPARE_RULES: jsonschema_diff.core.tools.compare.COMPARE_RULES_TYPE¶
- COMBINE_RULES: jsonschema_diff.core.tools.combine.COMBINE_RULES_TYPE = []¶
- PATH_MAKER_IGNORE: jsonschema_diff.core.tools.render.PATH_MAKER_IGNORE_RULES_TYPE = ['properties', 'items']¶
- PAIR_CONTEXT_RULES: jsonschema_diff.core.tools.context.PAIR_CONTEXT_RULES_TYPE = []¶
- CONTEXT_RULES: jsonschema_diff.core.tools.context.CONTEXT_RULES_TYPE¶
- COMPARE_CONFIG: COMPARE_CONFIG_TYPE¶
Configs for comparators. Can be obtained from Compare.my_config (content can be anything)
- PROPERTY_KEY_GROUPS: PROPERTY_KEY_GROUPS_TYPE¶
- class Property(
- config: jsonschema_diff.core.config.Config,
- schema_path: list[str | int],
- json_path: list[str | int],
- name: str | int | None,
- old_schema: dict | None,
- new_schema: dict | None,
- status: jsonschema_diff.core.abstraction.Statuses¶
- config¶
- name¶
- schema_path¶
- json_path¶
- old_schema¶
- new_schema¶
- calc_diff() dict[str, int][source]¶
Summarizes the difference statistics: - all parameters (Compare.calc_diff) - child properties (Property.calc_diff) - plus the status of the current Property (as a single observation)