Coverage for src/mafw/models/processor_schema.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-26 09:13 +0000

1# Copyright 2026 European Union 

2# Author: Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu) 

3# SPDX-License-Identifier: EUPL-1.2 

4"""Schemas describing a processor. 

5 

6These light-weight dataclasses capture the static metadata that is declared through 

7:class:`.base.Processor` definitions and can be consumed by tooling without instantiating 

8the processor itself. 

9""" 

10 

11from __future__ import annotations 

12 

13from dataclasses import dataclass 

14 

15from mafw.models.filter_schema import FilterSchema 

16from mafw.models.parameter_schema import ParameterSchema 

17 

18__all__ = ['ProcessorSchema'] 

19 

20 

21@dataclass(frozen=True) 

22class ProcessorSchema: 

23 """Static metadata describing a processor. 

24 

25 :param parameters: List of parameter schemas. 

26 :param filter: Optional filter schema. 

27 """ 

28 

29 parameters: list[ParameterSchema] 

30 filter: FilterSchema | None 

31 

32 def get_parameter_names(self) -> list[str]: 

33 """Return the list of parameter names.""" 

34 return [p.name for p in self.parameters] 

35 

36 def get_parameter(self, parameter_name: str) -> ParameterSchema: 

37 """Return the parameter schema for the given parameter name.""" 

38 for p in self.parameters: 

39 if p.name == parameter_name: 

40 return p 

41 raise KeyError(f'Parameter {parameter_name} not found in schema.')