|
| 1 | +# turing-smart-screen-python - a Python system monitor and library for USB-C displays like Turing Smart Screen or XuanFang |
| 2 | +# https://github.com/mathoudebine/turing-smart-screen-python/ |
| 3 | + |
| 4 | +# Copyright (C) 2021-2023 Matthieu Houdebine (mathoudebine) |
| 5 | +# |
| 6 | +# This program is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +# This file will use Python libraries (psutil, GPUtil, etc.) to get hardware sensors |
| 20 | +# For all platforms (Linux, Windows, macOS) but not all HW is supported |
| 21 | + |
| 22 | +from abc import ABC, abstractmethod |
| 23 | + |
| 24 | + |
| 25 | +class CustomDataSource(ABC): |
| 26 | + @abstractmethod |
| 27 | + def as_numeric(self) -> float: |
| 28 | + pass |
| 29 | + |
| 30 | + @abstractmethod |
| 31 | + def as_string(self) -> str: |
| 32 | + pass |
| 33 | + |
| 34 | + |
| 35 | +class ExampleCustomData(CustomDataSource): |
| 36 | + def as_numeric(self) -> float: |
| 37 | + return 50.4 |
| 38 | + |
| 39 | + def as_string(self) -> str: |
| 40 | + return f"{self.as_numeric()}%" |
0 commit comments