"""Import/export formats plugin — provides standard file formats as plugins. Part of the W4a contribution architecture (Spec #359): file formats live in this plugin instead of being hardcoded in the core orchestrator. New formats (e.g. PDF later) are added as additional format plugins without touching the core. Lifecycle: registers the bundled handlers (csv, json, xlsx) in the core format registry on activate, unregisters them on deactivate. """ from __future__ import annotations from typing import Any from app.core.importexport_registry import get_format_registry from app.plugins.base import BasePlugin from app.plugins.builtins.importexport_formats.formats import CsvFormat, JsonFormat, XlsxFormat from app.plugins.manifest import PluginManifest class ImportExportFormatsPlugin(BasePlugin): """Bundles the standard import/export file formats.""" manifest = PluginManifest( name="importexport_formats", version="1.0.0", display_name="Import/Export Formate", description="Standard-Formate für Import/Export: CSV, JSON, XLSX.", dependencies=[], routes=[], events=[], migrations=[], permissions=[], is_core=True, ) def __init__(self) -> None: super().__init__() self._handlers: list[Any] = [CsvFormat(), JsonFormat(), XlsxFormat()] async def on_activate(self, db, service_container, event_bus) -> None: await super().on_activate(db, service_container, event_bus) registry = get_format_registry() for handler in self._handlers: registry.register(handler) async def on_deactivate(self, db, service_container, event_bus) -> None: await super().on_deactivate(db, service_container, event_bus) registry = get_format_registry() for handler in self._handlers: registry.unregister(handler.format_id)