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
|
from datetime import datetime
|
||||||
import discord # type: ignore
|
import discord # type: ignore
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Try relative imports first
|
||||||
from ..utils.exceptions import ValidationError
|
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")
|
logger = logging.getLogger("VideoArchiver")
|
||||||
|
|
||||||
|
|
||||||
class ValidationResult(Enum):
|
class ValidationResult(Enum):
|
||||||
"""Possible validation results"""
|
"""Possible validation results"""
|
||||||
VALID = auto()
|
VALID = auto()
|
||||||
INVALID = auto()
|
INVALID = auto()
|
||||||
IGNORED = auto()
|
IGNORED = auto()
|
||||||
|
|
||||||
|
|
||||||
class ValidationStats(TypedDict):
|
class ValidationStats(TypedDict):
|
||||||
"""Type definition for validation statistics"""
|
"""Type definition for validation statistics"""
|
||||||
total: int
|
total: int
|
||||||
@@ -25,6 +32,7 @@ class ValidationStats(TypedDict):
|
|||||||
ignored: int
|
ignored: int
|
||||||
cached: int
|
cached: int
|
||||||
|
|
||||||
|
|
||||||
class ValidationCacheEntry(TypedDict):
|
class ValidationCacheEntry(TypedDict):
|
||||||
"""Type definition for validation cache entry"""
|
"""Type definition for validation cache entry"""
|
||||||
valid: bool
|
valid: bool
|
||||||
@@ -32,6 +40,7 @@ class ValidationCacheEntry(TypedDict):
|
|||||||
rule: Optional[str]
|
rule: Optional[str]
|
||||||
timestamp: str
|
timestamp: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ValidationContext:
|
class ValidationContext:
|
||||||
"""Context for message validation"""
|
"""Context for message validation"""
|
||||||
@@ -83,6 +92,7 @@ class ValidationContext:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValidationError(f"Failed to create validation context: {str(e)}")
|
raise ValidationError(f"Failed to create validation context: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ValidationRule:
|
class ValidationRule:
|
||||||
"""Defines a validation rule"""
|
"""Defines a validation rule"""
|
||||||
@@ -102,6 +112,7 @@ class ValidationRule:
|
|||||||
if self.priority < 0:
|
if self.priority < 0:
|
||||||
raise ValueError("Priority must be non-negative")
|
raise ValueError("Priority must be non-negative")
|
||||||
|
|
||||||
|
|
||||||
class ValidationCache:
|
class ValidationCache:
|
||||||
"""Caches validation results"""
|
"""Caches validation results"""
|
||||||
|
|
||||||
@@ -146,6 +157,7 @@ class ValidationCache:
|
|||||||
del self._cache[oldest]
|
del self._cache[oldest]
|
||||||
del self._access_times[oldest]
|
del self._access_times[oldest]
|
||||||
|
|
||||||
|
|
||||||
class ValidationRuleManager:
|
class ValidationRuleManager:
|
||||||
"""Manages validation rules"""
|
"""Manages validation rules"""
|
||||||
|
|
||||||
@@ -199,6 +211,7 @@ class ValidationRuleManager:
|
|||||||
return False, "User does not have required roles"
|
return False, "User does not have required roles"
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
|
|
||||||
class MessageValidator:
|
class MessageValidator:
|
||||||
"""Handles validation of messages for video processing"""
|
"""Handles validation of messages for video processing"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user