Coverage for klayout_pex/plugin_api/v1/pex25d_scene_exporter.py: 100%
7 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-06 13:14 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-06 13:14 +0000
1#
2# --------------------------------------------------------------------------------
3# SPDX-FileCopyrightText: 2024-2026 Martin Jan Köhler and Harald Pretl
4# Johannes Kepler University, Institute for Integrated Circuits.
5#
6# This file is part of KPEX
7# (see https://github.com/iic-jku/klayout-pex).
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21# SPDX-License-Identifier: GPL-3.0-or-later
22# --------------------------------------------------------------------------------
23#
25"""Version 1 PEX25D scene exporter protocol and its errors."""
27from __future__ import annotations
29from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Protocol
31if TYPE_CHECKING:
32 from klayout_pex_protobuf.kpex.pex25d.pex25d_scene_pb2 import PEX25DScene
35class ExportError(RuntimeError):
36 """The scene could not be written out for the requested target."""
39class ExporterUnavailable(ExportError):
40 """The backend for a target is not loadable in this installation."""
43class PEX25DSceneExporter(Protocol):
44 """Write solver inputs from a resolved ``PEX25DScene`` without running it.
46 The caller owns the scene; exporters must not mutate it. Implementations
47 validate their own options and reject unsupported features with ExportError.
48 NotImplementedError marks what an exporter does not implement yet.
49 Geometry libraries and other optional dependencies should be imported only
50 when needed, so metadata discovery remains usable without them.
51 """
53 def export(self,
54 scene: PEX25DScene,
55 *,
56 output_dir_path: str,
57 prefix: str = '',
58 options: Optional[Mapping[str, Any]] = None) -> List[str]:
59 """Return generated paths, primary input first, as in ``pex25d.export``.
61 ``scene`` is a resolved PEX25DScene protobuf message. ``options`` contains
62 backend-specific settings and must not be mutated. An empty ``prefix``
63 asks for the backend's default. Files are written under output_dir_path;
64 returned paths must be usable by the caller without changing directory.
65 """
66 ...
69__all__ = ['ExportError', 'ExporterUnavailable', 'PEX25DSceneExporter']