Source code for src.checks.interfaces_checked_in_binaries

from __future__ import annotations

from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
    from collections.abc import Hashable
    from pathlib import Path

from src.interfaces import Named


[docs] class FileTypeInterface: """Represents a recognized file type"""
[docs] def __init__(self): pass
[docs] def _key(self) -> tuple[Hashable, ...]: """Used to decide equality in comparisons and hash based lookups""" raise NotImplementedError
[docs] def __repr__(self) -> str: return str(self._key())
[docs] def __str__(self) -> str: return str(self._key())
[docs] def __hash__(self) -> int: return hash(self._key())
[docs] def __eq__(self, other: Any) -> bool: if isinstance(other, FileTypeInterface): return self._key() == other._key() raise NotImplementedError
[docs] class FileTypeToolInterface(Named): """Represents a tool that implements the mapping file -> file_type"""
[docs] def __init__(self): pass
[docs] def __repr__(self) -> str: return self.name()
[docs] def __str__(self) -> str: return self.name()
[docs] def file_type_of(self, file: Path) -> FileTypeInterface: raise NotImplementedError