sec_interp.exporters.base_exporter module
- class sec_interp.exporters.base_exporter.BaseExporter(settings: dict[str, Any])[source]
Bases:
ABCAbstract base class for all exporters.
This class defines the interface that all concrete exporters must implement. It follows the Template Method pattern, providing common initialization and validation logic while delegating format-specific export to subclasses.
- __init__(settings: dict[str, Any])[source]
Initialize the exporter with settings.
- Parameters:
settings – Dictionary containing export settings such as: - width: Output width in pixels - height: Output height in pixels - dpi: Dots per inch for resolution - background_color: Background color (QColor) - legend_renderer: Optional renderer for legend overlay
- abstractmethod export(output_path: Path, data: Any) bool[source]
Export data to file.
This method must be implemented by all concrete exporters.
- Parameters:
output_path – Destination file path
data – Data to export (format depends on exporter type)
- Returns:
True if export successful, False otherwise
- Return type:
bool
- get_setting(key: str, default: Any = None) Any[source]
Get a setting value with optional default.
- Parameters:
key – Setting key
default – Default value if key not found
- Returns:
Setting value or default
- abstractmethod get_supported_extensions() list[str][source]
Get list of supported file extensions.
- Returns:
List of supported extensions (e.g., [‘.png’, ‘.jpg’])
- validate_export_path(output_path: Path, base_dir: Path | None = None) tuple[bool, str][source]
Validate export path for security.
Uses secure path validation to prevent path traversal attacks.
- Parameters:
output_path – Path to validate
base_dir – Optional base directory to restrict exports to
- Returns:
(is_valid, error_message)
- Return type:
tuple