aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/hydrorollcore/rule.py
blob: eb4b92cd07783b3177ca884bad48b83dbe803c89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from abc import ABCMeta, abstractmethod
from enum import Enum

__all__ = ["RuleLoadType", "Rule"]


class RuleLoadType(Enum):
    """The Type Of Rules To Be Loaded"""

    DIR = "dir"
    NAME = "name"
    FILE = "file"
    CLASS = "class"


class Rule(metaclass=ABCMeta):
    @abstractmethod
    def __init__(self):
        pass

    @classmethod
    def __subclasshook__(cls, other):
        if cls is Rule:
            return hasattr(other, "run") and callable(getattr(other, "run"))
        return NotImplemented

    @abstractmethod
    async def run(self):
        pass