from typing import Tuple, List
from PIL import Image
from flask import Response
from PandaCore.common import logger
from PandaCore.utils import filepath


class ReleaseInterface(logger.Logger):
    """
    Interface class used to interact with release files
    """

    @classmethod
    def get_interface(cls, path) -> 'ReleaseInterface':
        from PandaCore.utils.filepath import file_has_archive_extension
        if file_has_archive_extension(path):
            interface = archive.ArchiveInterface(path)
        else:
            interface = folder.FolderInterface(path)
        return interface

    def get_files(self) -> List[str]:
        raise NotImplementedError

    def get_file_info(self, file: str) -> Tuple[int, int]:
        raise NotImplementedError

    def send_file(self, file: str) -> Response:
        raise NotImplementedError

    def get_image(self, file: str) -> Image:
        raise NotImplementedError

    def get_hash(self, file: str) -> str:
        raise NotImplementedError

    def get_sorted_files(self) -> List[str]:
        return filepath.human_sort(self.get_files())


from . import (
    archive,
    folder,
)
