hermes.commands.process.standard_merge
Attributes
The default match function used for comparison. |
|
A dict containing for JSON_LD types the match function (not DEFAULT_MATCH). |
|
A dict containing some common MergeActions. |
|
MergeActions for provenance values. |
|
MergeActions for the standard JSON_LD contexts objects. |
Classes
Base plugin that defines additional merge strategies. |
Functions
|
Compares two objects with ==. |
|
Creates a function taking to parameters that returns true |
|
Compares two objects assuming they are representing schema:Person's |
|
Returns a function that compares two objects using the given functions. |
Module Contents
- hermes.commands.process.standard_merge.match_equals(left: Any, right: Any) bool
Compares two objects with ==.
- Parameters:
left (Any) – The first object for the comparison.
right (Any) – The second object for the comparison.
- Returns:
The result of the comparison.
- Return type:
bool
- hermes.commands.process.standard_merge.match_keys(*keys: list[str], fall_back_to_equals: bool = False) Callable[[Any, Any], bool]
Creates a function taking to parameters that returns true if both given parameter have at least one common key in the given list of keys and for all common keys in the given list of keys the values of both objects are the same.
If fall_back_to_equals is True, the returned function returns the value of normal == comparison if no key from keys is in both objects.
- Parameters:
keys (list[str]) – The list of important keys for the comparison method.
fall_back_to_equals (bool) – Whether or not a fall back option should be used.
- Returns:
A function comparing two given objects values for the keys in keys.
- Return type:
Callable[[Any, Any], bool]
- hermes.commands.process.standard_merge.match_person(left: Any, right: Any) bool
Compares two objects assuming they are representing schema:Person’s if they are not ld_dicts, == is used as a fallback.
If both objects have an @id value, the truth value returned by this function is the comparison of both ids.
If either other has no @id value and both objects have at least one email value, they are considered equal if they have one common email.
If the equality of the objects is not yet decided, == comparison of the objects is returned.
- Parameters:
left (Any) – The first object for the comparison.
right (Any) – The second object for the comparison.
- Returns:
The result of the comparison.
- Return type:
bool
- hermes.commands.process.standard_merge.match_multiple_types(*functions_for_types: list[tuple[str, Callable[[Any, Any], bool]]], fall_back_function: Callable[[Any, Any], bool] = match_keys('@id', fall_back_to_equals=True)) Callable[[Any, Any], bool]
Returns a function that compares two objects using the given functions.
- Parameters:
functions_for_types (list[tuple[str, Callable[[Any, Any], bool]]]) – Tuples of type and match_function. The returned function will compare two objects of a the same, given type with the specified function.
fall_back_function (Callable[[Any, Any], bool]) – The fallback for comparison if the objects that are being compared don’t have a common type with specified compare function or at least one object is not a JSON-LD dictionary.
- Returns:
The function that compares the two given objects using the given functions.
- Return type:
Callable[[Any, Any], bool]
- hermes.commands.process.standard_merge.DEFAULT_MATCH
The default match function used for comparison.
- Type:
Callable[[Any, Any], bool]
- hermes.commands.process.standard_merge.MATCH_FUNCTION_FOR_TYPE
A dict containing for JSON_LD types the match function (not DEFAULT_MATCH).
- Type:
dict[str, Callable[[Any, Any], bool]]
- hermes.commands.process.standard_merge.ACTIONS
A dict containing some common MergeActions.
- Type:
dict[str, MergeAction]
- hermes.commands.process.standard_merge.PROV_STRATEGY
MergeActions for provenance values.
- Type:
dict[Literal[None], dict[str, MergeAction]]
- hermes.commands.process.standard_merge.CODEMETA_STRATEGY
MergeActions for the standard JSON_LD contexts objects.
- Type:
dict[str | None, dict[str | None, MergeAction]]
- class hermes.commands.process.standard_merge.CodemetaProcessPlugin
Bases:
hermes.commands.process.base.HermesProcessPluginBase plugin that defines additional merge strategies.
- __call__(command: hermes.commands.base.HermesCommand) hermes.commands.process.base.ObjectStrategies
Execute the hermes process plugin self.
- Parameters:
command (HermesProcessCommand) – The command being executed.
- Returns:
The merge strategies.
- Return type:
dict[str | None, dict[str | None, MergeAction]]