Add source models

This commit is contained in:
2026-01-29 21:21:21 +00:00
parent 0f4c01898f
commit 8c5ab77f8c

38
src/models/severity.py Normal file
View File

@@ -0,0 +1,38 @@
"""Severity levels for validation findings."""
from enum import Enum
class Severity(Enum):
"""Severity levels for validation findings."""
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
CRITICAL = "critical"
@classmethod
def from_string(cls, value: str) -> "Severity":
"""Create severity from string value."""
value_lower = value.lower()
for severity in cls:
if severity.value == value_lower:
return severity
raise ValueError(f"Unknown severity level: {value}")
def __lt__(self, other: "Severity") -> bool:
"""Compare severity levels."""
order = [Severity.LOW, Severity.MEDIUM, Severity.HIGH, Severity.CRITICAL]
return order.index(self) < order.index(other)
def __le__(self, other: "Severity") -> bool:
"""Compare severity levels (less than or equal)."""
return self == other or self < other
def __gt__(self, other: "Severity") -> bool:
"""Compare severity levels (greater than)."""
return not self <= other
def __ge__(self, other: "Severity") -> bool:
"""Compare severity levels (greater than or equal)."""
return not self < other