From 26f173ce72eca565f83da4805473ba691f8d79a3 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:10:44 +0000 Subject: [PATCH] fix(core): add fallback to absolute imports in cleanup.py --- videoarchiver/core/cleanup.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/videoarchiver/core/cleanup.py b/videoarchiver/core/cleanup.py index a286d1b..80df32a 100644 --- a/videoarchiver/core/cleanup.py +++ b/videoarchiver/core/cleanup.py @@ -8,15 +8,20 @@ from enum import Enum, auto from pathlib import Path from typing import TYPE_CHECKING, Dict, Any, Optional, TypedDict, ClassVar -from ..utils.file_ops import cleanup_downloads -from ..utils.exceptions import ( - CleanupError, - ErrorContext, - ErrorSeverity -) +try: + # Try relative imports first + from ..utils.file_ops import cleanup_downloads + from ..utils.exceptions import CleanupError, ErrorContext, ErrorSeverity +except ImportError: + # Fall back to absolute imports if relative imports fail + from videoarchiver.utils.file_ops import cleanup_downloads + from videoarchiver.utils.exceptions import CleanupError, ErrorContext, ErrorSeverity if TYPE_CHECKING: - from .base import VideoArchiver + try: + from .base import VideoArchiver + except ImportError: + from videoarchiver.core.base import VideoArchiver logger = logging.getLogger("VideoArchiver")