Spaces:
Sleeping
Sleeping
Download modules/dashboard/utils.py from sky-meilin/SkyOSFullCore: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/spaces/sky-meilin/SkyOSFullCore/resolve/main/modules/dashboard/utils.py
- Command line
-
hf download hf://spaces/sky-meilin/SkyOSFullCore/modules/dashboard/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/sky-meilin/SkyOSFullCore/resolve/main/modules/dashboard/utils.py
1.57 kB
| """ | |
| utils.py | |
| SkyOS Dashboard Utilities | |
| Gemeinsame Hilfsfunktionen für das Armaturenbrett. | |
| Autor: Sky Meilin | |
| Projekt: SkyOS | |
| """ | |
| from __future__ import annotations | |
| from datetime import datetime | |
| # --------------------------------------------------------- | |
| # Zeitfunktionen | |
| # --------------------------------------------------------- | |
| def current_timestamp() -> str: | |
| """ | |
| Erstellt einen formatierten Zeitstempel. | |
| """ | |
| return datetime.now().strftime( | |
| "%d.%m.%Y %H:%M:%S" | |
| ) | |
| def current_time() -> str: | |
| """ | |
| Liefert aktuelle Uhrzeit. | |
| """ | |
| return datetime.now().strftime( | |
| "%H:%M:%S" | |
| ) | |
| # --------------------------------------------------------- | |
| # Status Helfer | |
| # --------------------------------------------------------- | |
| def status_icon(active: bool) -> str: | |
| """ | |
| Gibt Statussymbol zurück. | |
| """ | |
| return "🟢" if active else "🔴" | |
| def format_status( | |
| name: str, | |
| active: bool, | |
| ) -> str: | |
| """ | |
| Erstellt eine Statusanzeige. | |
| """ | |
| return ( | |
| f"{status_icon(active)} {name}" | |
| ) | |
| # --------------------------------------------------------- | |
| # Text Helfer | |
| # --------------------------------------------------------- | |
| def clean_text(text: str | None) -> str: | |
| """ | |
| Bereinigt Benutzereingaben. | |
| """ | |
| if not text: | |
| return "" | |
| return text.strip() | |
| def limit_text( | |
| text: str, | |
| length: int = 100, | |
| ) -> str: | |
| """ | |
| Kürzt lange Texte für UI-Anzeigen. | |
| """ | |
| if len(text) <= length: | |
| return text | |
| return text[:length] + "..." |