initial
This commit is contained in:
30
app/classification/_protocols.py
Normal file
30
app/classification/_protocols.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import Protocol, Optional
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
class ClassificationRule:
|
||||
name: str
|
||||
category: str
|
||||
patterns: list[str]
|
||||
priority: int = 0
|
||||
description: str = ''
|
||||
|
||||
class IClassifier(Protocol):
|
||||
|
||||
def classify(self, path: Path, file_type: Optional[str]=None) -> Optional[str]:
|
||||
...
|
||||
|
||||
def get_category_rules(self, category: str) -> list[ClassificationRule]:
|
||||
...
|
||||
|
||||
class IRuleEngine(Protocol):
|
||||
|
||||
def add_rule(self, rule: ClassificationRule) -> None:
|
||||
...
|
||||
|
||||
def remove_rule(self, rule_name: str) -> None:
|
||||
...
|
||||
|
||||
def match_path(self, path: Path) -> Optional[str]:
|
||||
...
|
||||
Reference in New Issue
Block a user