Module i2pp.core.configuration_validator.validator

Module for validating and managing the configuration of the I2PP application.

Classes

class Discretization (path: pathlib.Path, type: str, options: Dict[str, Any] | None = <factory>)
Expand source code
@dataclass
class Discretization:
    """Class representing a discretization configuration."""

    path: Path
    type: str
    options: Optional[Dict[str, Any]] = field(default_factory=dict)

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "Discretization":
        """Creates a Discretization instance from a dictionary."""
        return Discretization(
            path=resolve_and_validate_path(d["path"]),
            type=d["type"],
            options=d.get("options", {}),  # Safe default if not provided
        )

Class representing a discretization configuration.

Static methods

def from_dict(d: Dict[str, Any]) ‑> Discretization
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "Discretization":
    """Creates a Discretization instance from a dictionary."""
    return Discretization(
        path=resolve_and_validate_path(d["path"]),
        type=d["type"],
        options=d.get("options", {}),  # Safe default if not provided
    )

Creates a Discretization instance from a dictionary.

Instance variables

var options : Dict[str, Any] | None
var path : pathlib.Path
var type : str
class Export (folder_path: pathlib.Path,
file_name: str,
type: str,
output_parameter_name: str | None = None)
Expand source code
@dataclass
class Export:
    """Class representing the export configuration."""

    folder_path: Path
    file_name: str
    type: str
    output_parameter_name: Optional[str] = None

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "Export":
        """Creates an Export instance from a dictionary."""
        return Export(
            folder_path=resolve_and_validate_path(
                d["folder_path"], must_exist=False
            ),
            file_name=d["file_name"],
            type=d["type"],
            output_parameter_name=d.get("output_parameter_name"),
        )

Class representing the export configuration.

Static methods

def from_dict(d: Dict[str, Any]) ‑> Export
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "Export":
    """Creates an Export instance from a dictionary."""
    return Export(
        folder_path=resolve_and_validate_path(
            d["folder_path"], must_exist=False
        ),
        file_name=d["file_name"],
        type=d["type"],
        output_parameter_name=d.get("output_parameter_name"),
    )

Creates an Export instance from a dictionary.

Instance variables

var file_name : str
var folder_path : pathlib.Path
var output_parameter_name : str | None
var type : str
class I2PPConfig (import_: Import,
processing: Processing,
export: Export)
Expand source code
@dataclass
class I2PPConfig:
    """Class representing the configuration for the I2PP application."""

    import_: Import
    processing: Processing
    export: Export

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "I2PPConfig":
        """Creates an I2PPConfig instance from a dictionary."""
        return I2PPConfig(
            import_=Import.from_dict(d["import"]),
            processing=Processing.from_dict(d["processing"]),
            export=Export.from_dict(d["export"]),
        )

Class representing the configuration for the I2PP application.

Static methods

def from_dict(d: Dict[str, Any]) ‑> I2PPConfig
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "I2PPConfig":
    """Creates an I2PPConfig instance from a dictionary."""
    return I2PPConfig(
        import_=Import.from_dict(d["import"]),
        processing=Processing.from_dict(d["processing"]),
        export=Export.from_dict(d["export"]),
    )

Creates an I2PPConfig instance from a dictionary.

Instance variables

var exportExport
var import_Import
var processingProcessing
class Image (path: pathlib.Path, type: str, options: Dict[str, Any] = <factory>)
Expand source code
@dataclass
class Image:
    """Class representing an image configuration."""

    path: Path
    type: str
    options: Dict[str, Any] = field(default_factory=dict)

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "Image":
        """Creates an Image instance from a dictionary."""
        return Image(
            path=resolve_and_validate_path(d["path"]),
            type=d["type"],
            options=(d["options"] if "options" in d else {}),
        )

Class representing an image configuration.

Static methods

def from_dict(d: Dict[str, Any]) ‑> Image
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "Image":
    """Creates an Image instance from a dictionary."""
    return Image(
        path=resolve_and_validate_path(d["path"]),
        type=d["type"],
        options=(d["options"] if "options" in d else {}),
    )

Creates an Image instance from a dictionary.

Instance variables

var options : Dict[str, Any]
var path : pathlib.Path
var type : str
class Import (discretization: Discretization,
image: Image)
Expand source code
@dataclass
class Import:
    """Class representing the import configuration for discretization and image
    data."""

    discretization: Discretization
    image: Image

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "Import":
        """Creates an Import instance from a dictionary."""
        return Import(
            discretization=Discretization.from_dict(d["discretization"]),
            image=Image.from_dict(d["image"]),
        )

Class representing the import configuration for discretization and image data.

Static methods

def from_dict(d: Dict[str, Any]) ‑> Import
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "Import":
    """Creates an Import instance from a dictionary."""
    return Import(
        discretization=Discretization.from_dict(d["discretization"]),
        image=Image.from_dict(d["image"]),
    )

Creates an Import instance from a dictionary.

Instance variables

var discretizationDiscretization
var imageImage
class Processing (interpolation_method: str,
smoothing: Smoothing | None,
transformation: Transformation)
Expand source code
@dataclass
class Processing:
    """Class representing the processing configuration."""

    interpolation_method: str
    smoothing: Optional[Smoothing]
    transformation: Transformation

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "Processing":
        """Creates a Processing instance from a dictionary."""
        return Processing(
            interpolation_method=d["interpolation_method"],
            smoothing=(
                Smoothing.from_dict(d["smoothing"])
                if d.get("smoothing") is not None
                else None
            ),
            transformation=Transformation.from_dict(d["transformation"]),
        )

Class representing the processing configuration.

Static methods

def from_dict(d: Dict[str, Any]) ‑> Processing
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "Processing":
    """Creates a Processing instance from a dictionary."""
    return Processing(
        interpolation_method=d["interpolation_method"],
        smoothing=(
            Smoothing.from_dict(d["smoothing"])
            if d.get("smoothing") is not None
            else None
        ),
        transformation=Transformation.from_dict(d["transformation"]),
    )

Creates a Processing instance from a dictionary.

Instance variables

var interpolation_method : str
var smoothingSmoothing | None
var transformationTransformation
class Smoothing (smoothing_area: int = 3, visualize: bool = False)
Expand source code
@dataclass
class Smoothing:
    """Class representing the smoothing configuration."""

    smoothing_area: int = 3
    visualize: bool = False

    @staticmethod
    def from_dict(d: Optional[Dict[str, Any]]) -> Optional["Smoothing"]:
        """Creates a Smoothing instance from a dictionary."""
        if d is None:
            return None
        return Smoothing(
            smoothing_area=d.get("smoothing_area", 3),
            visualize=d.get("visualize", False),
        )

Class representing the smoothing configuration.

Static methods

def from_dict(d: Dict[str, Any] | None) ‑> Smoothing | None
Expand source code
@staticmethod
def from_dict(d: Optional[Dict[str, Any]]) -> Optional["Smoothing"]:
    """Creates a Smoothing instance from a dictionary."""
    if d is None:
        return None
    return Smoothing(
        smoothing_area=d.get("smoothing_area", 3),
        visualize=d.get("visualize", False),
    )

Creates a Smoothing instance from a dictionary.

Instance variables

var smoothing_area : int
var visualize : bool
class Transformation (user_script: pathlib.Path,
user_function: str,
normalize_values: bool = False,
visualize: bool = False)
Expand source code
@dataclass
class Transformation:
    """Class representing the transformation configuration."""

    user_script: Path
    user_function: str
    normalize_values: bool = False
    visualize: bool = False

    @staticmethod
    def from_dict(d: Dict[str, Any]) -> "Transformation":
        """Creates a Transformation instance from a dictionary."""
        return Transformation(
            user_script=resolve_and_validate_path(d["user_script"]),
            user_function=d["user_function"],
            normalize_values=d.get("normalize_values", False),
            visualize=d.get("visualize", False),
        )

Class representing the transformation configuration.

Static methods

def from_dict(d: Dict[str, Any]) ‑> Transformation
Expand source code
@staticmethod
def from_dict(d: Dict[str, Any]) -> "Transformation":
    """Creates a Transformation instance from a dictionary."""
    return Transformation(
        user_script=resolve_and_validate_path(d["user_script"]),
        user_function=d["user_function"],
        normalize_values=d.get("normalize_values", False),
        visualize=d.get("visualize", False),
    )

Creates a Transformation instance from a dictionary.

Instance variables

var normalize_values : bool
var user_function : str
var user_script : pathlib.Path
var visualize : bool