schon/evibes/utils/misc.py
Egor fureunoir Gorbunov 3228a89d4b Features:
1) Add new `test_graphene` test module for expanded testing coverage;
2) Introduce `test_drf` module in `engine/blog` for improved API testing;

Fixes:
1) Remove unnecessary `--extra testing` flag from Dockerfile to streamline dependencies;
2) Update `uv.lock` with newer versions of dependencies (`certifi`, `coverage`, `django-constance`) for enhanced security and functionality;

Extra:
1) Remove deprecated packages (`bandit`, `cfgv`, `distlib`) from `uv.lock` for cleanup;
2) Adjust `uv.lock` content and formatting to be consistent with updated dependencies.
2025-11-13 15:24:44 +03:00

43 lines
976 B
Python

from enum import Enum
from importlib import import_module
from typing import Any
from django.core.exceptions import PermissionDenied
def create_object(module_name: str, class_name: str, *args: list[Any], **kwargs: dict[Any, Any]) -> Any:
module = import_module(module_name)
cls = getattr(module, class_name)
return cls(*args, **kwargs)
class LoggingError(Exception):
pass
class LogLevel(Enum):
DEBUG = "debug"
INFO = "info"
WARNING = "warning"
ERROR = "error"
CRITICAL = "critical"
TRACE = "trace"
class RatelimitedError(Exception):
default_detail = "Rate limit exceeded. Please try again later."
default_code = "rate_limited"
status_code = 429
def __init__(self, detail=None, code=None):
if detail is None:
detail = self.default_detail
if code is None:
code = self.default_code
self.detail = detail
self.code = code
super().__init__(detail)