# sec_interp.core.utils.safe_loader module

Module for safe and lazy loading of plugin components.

Provides utilities to catch import and initialization errors, allowing the core plugin to remain functional even if some modules fail.

class sec_interp.core.utils.safe_loader.SafeLoader

  Bases: `object`

  Handles safe and lazy loading of modules and classes.

  static get_class(module: Any, class_name: str) → type | None

    Get a class from a module safely.

  static lazy_load(module_name: str, class_name: str, fallback_factory: Callable[[], T] | None = None, *args: Any, **kwargs: Any) → T | None

    Lazy load and instantiate a class safely with arguments.

    Parameters:

      - module_name – Module to load from.

      - class_name – Class to instantiate.

      - fallback_factory – Optional factory to create a fallback instance.

      - *args – Positional arguments for the class constructor.

      - **kwargs – Keyword arguments for the class constructor.

    Returns:

      An instance of the class or None/Fallback if loading failed.

  static safe_import(module_name: str, error_message: str | None = None) → Any

    Import a module safely, logging errors instead of crashing.

    Parameters:

      - module_name – Full path to the module.

      - error_message – Optional custom error message.

    Returns:

      The loaded module or None if it failed.