Files
3d.lehrstun.de/services/drucker_links.py
Hans Puettmann 3482356c13 Drucker-Bestand korrigiert: X1C -> H2S
Real-Stand laut Herb: 2x P1S, 1x H2S, 1x A1 mini. X1C/P2S bleiben in
drucker_links als Default-Mapping fuer den Fall, dass die Modelle spaeter
dazukommen.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 19:53:34 +02:00

62 lines
2.2 KiB
Python

"""Default-Manual + Troubleshooting-Links pro Drucker-Modell.
Bambu-Wiki-URLs als Startpunkt — koennen pro konkretem Drucker in der
DB via drucker.manual_url / drucker.troubleshooting_url ueberschrieben
werden (Inline-Edit). Wenn Override gesetzt, gewinnt der.
"""
MODELL_LINKS = {
"P1S": {
"manual": "https://wiki.bambulab.com/en/p1",
"troubleshooting": "https://wiki.bambulab.com/en/p1/troubleshooting",
},
"H2S": {
# H2 Series — Bambu's neueres High-End-Modell. Wiki-URL pruefen und
# ggf. per Admin-UI per drucker.manual_url ueberschreiben, sobald
# Bambu seine Doku-Struktur stabilisiert hat.
"manual": "https://wiki.bambulab.com/en/h2s",
"troubleshooting": "https://wiki.bambulab.com/en/h2s/troubleshooting",
},
"A1 mini": {
"manual": "https://wiki.bambulab.com/en/a1-mini",
"troubleshooting": "https://wiki.bambulab.com/en/a1-mini/troubleshooting",
},
# Aelterer Bestand fuer den Fall, dass eines der Modelle dazukommt
"X1C": {
"manual": "https://wiki.bambulab.com/en/x1",
"troubleshooting": "https://wiki.bambulab.com/en/x1/troubleshooting",
},
"P2S": {
"manual": "https://wiki.bambulab.com/de/p2s/manual/p2s-intro",
"troubleshooting": "https://wiki.bambulab.com/en/p2/troubleshooting",
},
}
def drucker_links(drucker):
"""Liefert (manual_url, troubleshooting_url) fuer einen Drucker.
Order of resolution: DB-Override > Modell-Default > None.
`drucker` darf ein sqlite3.Row oder dict sein — Hauptsache es hat
die Schluessel modell, manual_url, troubleshooting_url.
"""
modell = drucker["modell"] if drucker else None
default = MODELL_LINKS.get(modell, {})
return {
"manual": _trim(drucker, "manual_url") or default.get("manual"),
"troubleshooting": _trim(drucker, "troubleshooting_url") or default.get("troubleshooting"),
}
def _trim(drucker, schluessel):
"""Liest ein optionales Feld aus dem Row/Dict, gibt None wenn leer."""
try:
wert = drucker[schluessel]
except (KeyError, IndexError):
return None
if not wert:
return None
wert = wert.strip()
return wert or None