1
0

Kompletter Rewrite

This commit is contained in:
Akamaru
2025-09-08 17:19:22 +02:00
parent edf0012917
commit 7e377363c6
18 changed files with 1688 additions and 1052 deletions

39
models/program.py Normal file
View File

@@ -0,0 +1,39 @@
from dataclasses import dataclass
from typing import Optional
@dataclass
class Program:
name: str
path: str
category: Optional[str] = None
requires_admin: bool = False
def __post_init__(self):
if not self.name:
raise ValueError("Program name cannot be empty")
if not self.path:
raise ValueError("Program path cannot be empty")
def to_dict(self) -> dict:
result = {
"Name": self.name,
"Pfad": self.path
}
if self.category:
result["Kategorie"] = self.category
if self.requires_admin:
result["Adminrechte"] = True
return result
@classmethod
def from_dict(cls, data: dict) -> 'Program':
return cls(
name=data["Name"],
path=data["Pfad"],
category=data.get("Kategorie"),
requires_admin=data.get("Adminrechte", False)
)
def __str__(self) -> str:
return f"{self.name} ({self.category or 'Ohne Kategorie'})"