mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -05:00
fix(processor): add fallback to absolute imports in message_validator.py
This commit is contained in:
@@ -7,16 +7,23 @@ from typing import Dict, Optional, Tuple, List, Any, Callable, Set, TypedDict, C
|
||||
from datetime import datetime
|
||||
import discord # type: ignore
|
||||
|
||||
try:
|
||||
# Try relative imports first
|
||||
from ..utils.exceptions import ValidationError
|
||||
except ImportError:
|
||||
# Fall back to absolute imports if relative imports fail
|
||||
from videoarchiver.utils.exceptions import ValidationError
|
||||
|
||||
logger = logging.getLogger("VideoArchiver")
|
||||
|
||||
|
||||
class ValidationResult(Enum):
|
||||
"""Possible validation results"""
|
||||
VALID = auto()
|
||||
INVALID = auto()
|
||||
IGNORED = auto()
|
||||
|
||||
|
||||
class ValidationStats(TypedDict):
|
||||
"""Type definition for validation statistics"""
|
||||
total: int
|
||||
@@ -25,6 +32,7 @@ class ValidationStats(TypedDict):
|
||||
ignored: int
|
||||
cached: int
|
||||
|
||||
|
||||
class ValidationCacheEntry(TypedDict):
|
||||
"""Type definition for validation cache entry"""
|
||||
valid: bool
|
||||
@@ -32,6 +40,7 @@ class ValidationCacheEntry(TypedDict):
|
||||
rule: Optional[str]
|
||||
timestamp: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ValidationContext:
|
||||
"""Context for message validation"""
|
||||
@@ -83,6 +92,7 @@ class ValidationContext:
|
||||
except Exception as e:
|
||||
raise ValidationError(f"Failed to create validation context: {str(e)}")
|
||||
|
||||
|
||||
@dataclass
|
||||
class ValidationRule:
|
||||
"""Defines a validation rule"""
|
||||
@@ -102,6 +112,7 @@ class ValidationRule:
|
||||
if self.priority < 0:
|
||||
raise ValueError("Priority must be non-negative")
|
||||
|
||||
|
||||
class ValidationCache:
|
||||
"""Caches validation results"""
|
||||
|
||||
@@ -146,6 +157,7 @@ class ValidationCache:
|
||||
del self._cache[oldest]
|
||||
del self._access_times[oldest]
|
||||
|
||||
|
||||
class ValidationRuleManager:
|
||||
"""Manages validation rules"""
|
||||
|
||||
@@ -199,6 +211,7 @@ class ValidationRuleManager:
|
||||
return False, "User does not have required roles"
|
||||
return True, None
|
||||
|
||||
|
||||
class MessageValidator:
|
||||
"""Handles validation of messages for video processing"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user