File: ConfigBase.py

package info (click to toggle)
python-nxtomomill 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,340 kB
  • sloc: python: 17,207; makefile: 15; sh: 3
file content (30 lines) | stat: -rw-r--r-- 971 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import annotations

from nxtomomill.utils.io import deprecated


class ConfigBase:
    """
    Base class for models that can produce a configuration file (.cfg) to be provided to one of the converter.

    The configuration is setting inputs for the different conversion functions / classes.
    We expect config classes / models to inherit from this class and from a pydantic model.
    """

    def to_cfg_file(self, file_path: str, filter_sections: tuple[str] = tuple()):
        raise NotImplementedError

    @classmethod
    def from_cfg_file(cls, file_path: str) -> ConfigBase:
        raise NotImplementedError

    @deprecated(
        reason="Replaced by pydantic function 'model_dump'", since_version="2.0"
    )
    def to_dict(self) -> dict:
        return self.model_dump()  # pylint: disable=E1101

    @staticmethod
    def from_dict(dict_: dict) -> None:
        """.. warning:: deprecated since 2.0"""
        raise NotImplementedError