diff --git a/src/nostr/__init__.py b/src/nostr/__init__.py index 5f65186..6afdc68 100644 --- a/src/nostr/__init__.py +++ b/src/nostr/__init__.py @@ -1,21 +1,16 @@ # nostr/__init__.py -import logging -import traceback -from .client import NostrClient +"""Nostr package exposing :class:`NostrClient` lazily.""" + +from importlib import import_module +import logging -# Instantiate the logger logger = logging.getLogger(__name__) -# Initialize the logger for this module -logger = logging.getLogger(__name__) # Correct logger initialization - -try: - from .client import NostrClient - - logger.info("NostrClient module imported successfully.") -except Exception as e: - logger.error(f"Failed to import NostrClient module: {e}") - logger.error(traceback.format_exc()) # Log full traceback - __all__ = ["NostrClient"] + + +def __getattr__(name: str): + if name == "NostrClient": + return import_module(".client", __name__).NostrClient + raise AttributeError(f"module '{__name__}' has no attribute '{name}'") diff --git a/src/password_manager/__init__.py b/src/password_manager/__init__.py index 9534afc..97b0288 100644 --- a/src/password_manager/__init__.py +++ b/src/password_manager/__init__.py @@ -1,30 +1,17 @@ # password_manager/__init__.py -import logging -import traceback +"""Expose password manager components with lazy imports.""" -try: - from .manager import PasswordManager - - logging.info("PasswordManager module imported successfully.") -except Exception as e: - logging.error(f"Failed to import PasswordManager module: {e}") - logging.error(traceback.format_exc()) # Log full traceback - -try: - from .config_manager import ConfigManager - - logging.info("ConfigManager module imported successfully.") -except Exception as e: - logging.error(f"Failed to import ConfigManager module: {e}") - logging.error(traceback.format_exc()) - -try: - from .vault import Vault - - logging.info("Vault module imported successfully.") -except Exception as e: - logging.error(f"Failed to import Vault module: {e}") - logging.error(traceback.format_exc()) +from importlib import import_module __all__ = ["PasswordManager", "ConfigManager", "Vault"] + + +def __getattr__(name: str): + if name == "PasswordManager": + return import_module(".manager", __name__).PasswordManager + if name == "ConfigManager": + return import_module(".config_manager", __name__).ConfigManager + if name == "Vault": + return import_module(".vault", __name__).Vault + raise AttributeError(f"module '{__name__}' has no attribute '{name}'")