Debian Codegraph @

src/nitrokey/trussed/_bootloader/lpc55_upload/utils/abstract.py

raw
1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 #
4 # Copyright 2019-2023 NXP
5 #
6 # SPDX-License-Identifier: BSD-3-Clause
7
8 """Module for base abstract classes."""
9
10 from abc import ABC, abstractmethod
11 from typing import Any
12
13
14 ########################################################################################################################
15 # Abstract Class for Data Classes
16 ########################################################################################################################
17 class BaseClass(ABC):
18 """Abstract Class for Data Classes."""
19
20 def __eq__(self, obj: Any) -> bool:
21 """Check object equality."""
22 return isinstance(obj, self.__class__) and vars(obj) == vars(self)
23
24 def __ne__(self, obj: Any) -> bool:
25 return not self.__eq__(obj)
26
27 @abstractmethod
28 def __repr__(self) -> str:
29 """Object representation in string format."""
30
31 @abstractmethod
32 def __str__(self) -> str:
33 """Object description in string format."""