# Path: crowd_anki/anki/adapters/file_provider.py
# class FileProvider(ABC):
#     @abstractmethod
#     def get_files(self, ) -> set:
#         pass


import os
from dataclasses import dataclass, field
from functional import seq
from typing import Any, Iterable, Set
from anki.exporting import AnkiExporter
from .file_provider import FileProvider




@dataclass
class NoteModelFileProvider(FileProvider):
    anki_collection: Any
    model_ids: Iterable[int]
    models: Iterable = field(init=False)
    anki_exporter: AnkiExporter = field(init=False)

    def __post_init__(self):
        self.anki_exporter = AnkiExporter(self.anki_collection)
        self.models = seq(self.model_ids) \
            .map(self.anki_collection.models.get) \
            .filter(lambda m: m is not None).to_list()

    def get_files(self) -> Set[str]:
        return seq(os.listdir(self.anki_collection.media.dir())) \
            .filter(lambda fn: fn.startswith("_")) \

# Path: crowd_anki/anki/adapters/file_provider.py
# class FileProvider(ABC):
#     @abstractmethod
#     def get_files(self, ) -> set:
#         pass


# Path: crowd_anki/anki/adapters/note_model_file_provider.py
import os
from dataclasses import dataclass, field
from functional import seq
from typing import Any, Iterable, Set
from anki.exporting import AnkiExporter
from .file_provider import FileProvider





@dataclass
class NoteModelFileProvider(FileProvider):
    anki_collection: Any
    model_ids: Iterable[int]
    models: Iterable = field(init=False)
    anki_exporter: AnkiExporter = field(init=False)

    def __post_init__(self):
        self.anki_exporter = AnkiExporter(self.anki_collection)
        self.models = seq(self.model_ids) \
            .map(self.anki_collection.models.get) \
            .filter(lambda m: m is not None).to_list()

    def get_files(self) -> Set[str]:
        return seq(os.listdir(self.anki_collection.media.dir())) \
            .filter(lambda fn: fn.startswith("_")) \

            .filter(self.belongs_to_any_model) \