Add dependency scanning and optional dependency checks

This commit is contained in:
thePR0M3TH3AN committed 2025-08-05 21:04:50 -04:00
1 parent c2d80aa438
commit 68eaa34d76
5 files changed
+89 -55

No files matched your search

+40 -36
View File
@@ -1,47 +1,51 @@
# utils/__init__.py
"""Utility package exports and optional feature handling."""
import logging
import traceback
logger = logging.getLogger(__name__)
try:
from .file_lock import exclusive_lock, shared_lock
from .key_derivation import (
derive_key_from_password,
derive_key_from_parent_seed,
derive_index_key,
derive_totp_secret,
EncryptionMode,
DEFAULT_ENCRYPTION_MODE,
TOTP_PURPOSE,
)
from .checksum import (
calculate_checksum,
verify_checksum,
json_checksum,
canonical_json_dumps,
initialize_checksum,
update_checksum_file,
)
from .password_prompt import prompt_for_password
from .seed_prompt import masked_input, prompt_seed_words
from .input_utils import timed_input
from .memory_protection import InMemorySecret
from .file_lock import exclusive_lock, shared_lock
from .key_derivation import (
derive_key_from_password,
derive_key_from_parent_seed,
derive_index_key,
derive_totp_secret,
EncryptionMode,
DEFAULT_ENCRYPTION_MODE,
TOTP_PURPOSE,
)
from .checksum import (
calculate_checksum,
verify_checksum,
json_checksum,
canonical_json_dumps,
initialize_checksum,
update_checksum_file,
)
from .password_prompt import prompt_for_password
from .seed_prompt import masked_input, prompt_seed_words
from .input_utils import timed_input
from .memory_protection import InMemorySecret
from .terminal_utils import (
clear_screen,
pause,
clear_and_print_fingerprint,
clear_header_with_notification,
)
from .atomic_write import atomic_write
# Optional clipboard support
try: # pragma: no cover - exercised when dependency missing
from .clipboard import copy_to_clipboard
from .terminal_utils import (
clear_screen,
pause,
clear_and_print_fingerprint,
clear_header_with_notification,
)
from .atomic_write import atomic_write
except Exception as exc: # pragma: no cover - executed only if pyperclip missing
def copy_to_clipboard(*_args, **_kwargs):
"""Stub when clipboard support is unavailable."""
logger.warning("Clipboard support unavailable: %s", exc)
return False
if logger.isEnabledFor(logging.DEBUG):
logger.info("Modules imported successfully.")
except Exception as e:
if logger.isEnabledFor(logging.DEBUG):
logger.error(f"Failed to import one or more modules: {e}", exc_info=True)
__all__ = [
"derive_key_from_password",