# sec_interp.core.utils.resource_manager module

Resource management utilities for SecInterp.

This module provides context managers for handling temporary QGIS resources and system files to ensure proper cleanup and prevent resource leaks.

sec_interp.core.utils.resource_manager.temporary_memory_layer(uri: str, name: str, provider: str = 'memory') → Generator[qgis.core.QgsVectorLayer, None, None]

  Context manager for a temporary QGIS memory layer.

  The layer is created and optionally added to the project. It is automatically removed from the project and deleted when the context exits.

  Parameters:

    - uri – Layer URI (e.g., “LineString?crs=EPSG:4326”).

    - name – Layer name for display.

    - provider – Provider ID (default “memory”).

  Yields:

    The created temporary layer.

sec_interp.core.utils.resource_manager.temporary_file(suffix: str | None = None, prefix: str | None = None, dir: str | None = None) → Generator[str, None, None]

  Context manager for a temporary file path.

  Creates a temporary file and yields its absolute path. The file is automatically deleted when the context exits.

  Parameters:

    - suffix – File suffix.

    - prefix – File prefix.

    - dir – Directory to create the file in.

  Yields:

    Absolute path to the temporary file.

class sec_interp.core.utils.resource_manager.ResourceManager

  Bases: `object`

  Consolidated resource manager for plugin-wide cleanup.

  static cleanup_layer(layer: qgis.core.QgsMapLayer)

    Remove a layer safely from the project.

    Parameters:

      layer – The QGIS map layer to remove.