Skip to content

Specification entry

DiffObjectSpecificationEntry

Bases: ABC

Source code in src/officialeye/_internal/diffobject/specification_entry.py
class DiffObjectSpecificationEntry(ABC):

    def __init__(self, validator: yml.Validator, /):
        self._validator = validator

    def get_schema(self) -> yml.Validator:
        """ Retrieves a schema for the current specification entry. """
        return self._validator

    @abc.abstractmethod
    def apply_diff(self, current_value: any, diff_value: any, diff_mode: str) -> any:
        """
        Calculates a new value for an entry, based on currently available value, some provided value, and a way of combining them.

        Arguments:
            current_value: The current value assigned to the entry, or None if there is no such value.
            diff_value: A new value provided for this entry.
            diff_mode: How the two values are to be combined to form a new value.

        Returns:
            The new value obtained by combining current_value with diff_value using diff_mode.

        Raises:
            DiffObjectException: If the difference mode cannot be applied to the present entry, for example, due to its type.
        """
        raise NotImplementedError()

apply_diff(current_value, diff_value, diff_mode) abstractmethod

Calculates a new value for an entry, based on currently available value, some provided value, and a way of combining them.

Parameters:

Name Type Description Default
current_value any

The current value assigned to the entry, or None if there is no such value.

required
diff_value any

A new value provided for this entry.

required
diff_mode str

How the two values are to be combined to form a new value.

required

Returns:

Type Description
any

The new value obtained by combining current_value with diff_value using diff_mode.

Raises:

Type Description
DiffObjectException

If the difference mode cannot be applied to the present entry, for example, due to its type.

Source code in src/officialeye/_internal/diffobject/specification_entry.py
@abc.abstractmethod
def apply_diff(self, current_value: any, diff_value: any, diff_mode: str) -> any:
    """
    Calculates a new value for an entry, based on currently available value, some provided value, and a way of combining them.

    Arguments:
        current_value: The current value assigned to the entry, or None if there is no such value.
        diff_value: A new value provided for this entry.
        diff_mode: How the two values are to be combined to form a new value.

    Returns:
        The new value obtained by combining current_value with diff_value using diff_mode.

    Raises:
        DiffObjectException: If the difference mode cannot be applied to the present entry, for example, due to its type.
    """
    raise NotImplementedError()

get_schema()

Retrieves a schema for the current specification entry.

Source code in src/officialeye/_internal/diffobject/specification_entry.py
def get_schema(self) -> yml.Validator:
    """ Retrieves a schema for the current specification entry. """
    return self._validator