Skip to content

protocols

flavor.psp.protocols

PSP Protocol Definitions - Type-safe interfaces for PSP operations.

Defines protocols for common PSP operations that can be implemented by different format versions (PSPF/2025, future formats, etc.).

Classes

ExtractorProtocol

Bases: Protocol

Protocol for package slot extraction.

Functions
extract_slot
extract_slot(
    slot_index: int,
    dest_dir: Path,
    *,
    verify_checksum: bool = True
) -> Path

Extract a specific slot to a directory.

Parameters:

Name Type Description Default
slot_index int

Index of the slot to extract

required
dest_dir Path

Destination directory for extraction

required
verify_checksum bool

Whether to verify checksums during extraction

True

Returns:

Type Description
Path

Path to the extracted content

Source code in flavor/psp/protocols.py
def extract_slot(  # pragma: no cover
    self, slot_index: int, dest_dir: Path, *, verify_checksum: bool = True
) -> Path:
    """Extract a specific slot to a directory.

    Args:
        slot_index: Index of the slot to extract
        dest_dir: Destination directory for extraction
        verify_checksum: Whether to verify checksums during extraction

    Returns:
        Path to the extracted content
    """
    ...

IntegrityResult

Bases: TypedDict

Result of package integrity verification.

IntegrityVerifierProtocol

Bases: Protocol

Protocol for package integrity verification.

Any class that implements this protocol can verify package integrity, regardless of the underlying format implementation.

Functions
verify_integrity
verify_integrity(bundle_path: Path) -> IntegrityResult

Verify the integrity of a package bundle.

Parameters:

Name Type Description Default
bundle_path Path

Path to the package bundle file

required

Returns:

Type Description
IntegrityResult

IntegrityResult dictionary with verification status

Source code in flavor/psp/protocols.py
def verify_integrity(self, bundle_path: Path) -> IntegrityResult:  # pragma: no cover
    """Verify the integrity of a package bundle.

    Args:
        bundle_path: Path to the package bundle file

    Returns:
        IntegrityResult dictionary with verification status
    """
    ...