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.