Source code for src.checks.interfaces_checked_in_binaries

from __future__ import annotations
from typing import Hashable, Tuple
from pathlib import Path


[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) -> bool: if isinstance(other, FileTypeInterface): return self._key() == other._key() raise NotImplementedError
[docs] class FileTypeToolInterface: """Represents a tool that implements the mapping file -> file_type"""
[docs] def __init__(self): pass
@classmethod @property def name(cls) -> str: return cls.__name__
[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