# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/mxns/05_expt.ipynb.

# %% auto 0
__all__ = ['ExpectedMixin']

# %% ../../nbs/mxns/05_expt.ipynb 6
import os, pathlib
from abc import abstractmethod

# %% ../../nbs/mxns/05_expt.ipynb 8
from typing import Callable, Optional, Iterable

# %% ../../nbs/mxns/05_expt.ipynb 10
from atyp import PathType
from nlit import (PathKind, )

from chck.path import ispath

# %% ../../nbs/mxns/05_expt.ipynb 12
from .reqr import RequiredMixin

# %% ../../nbs/mxns/05_expt.ipynb 14
class ExpectedMixin(RequiredMixin):
    aspec: tuple = ('expected', )
    expected: tuple['ExpectedMixin', ... ] = ()
    
    def makeprops(self, **kwargs):
        for i, e in enumerate(self.expected):
            setattr(type(self), e.name, property(lambda self: self.expected[i]))

    def __init__(self, path: PathType, *args, **kwargs):
        super().__init__(path, *args, **kwargs)
        self.makeprops()


    def isvalid(self) -> bool: 
        if not self.required: return True
        return self.path.exists() and all((self.path / e).exists() for e in self.expected)
