update
This commit is contained in:
@@ -548,6 +548,21 @@ def fetch_openai_usage(client) -> dict:
|
||||
return None
|
||||
|
||||
|
||||
def _coerce_autotext_entry_values(entries):
|
||||
"""Stellt sicher, dass Autotext-Einträge String-Werte haben (globaler Hook)."""
|
||||
out = {}
|
||||
if not isinstance(entries, dict):
|
||||
return out
|
||||
for k, v in entries.items():
|
||||
if not isinstance(k, str) or not k.strip():
|
||||
continue
|
||||
if isinstance(v, str):
|
||||
out[k] = v
|
||||
elif isinstance(v, dict) and "text" in v:
|
||||
out[k] = str(v.get("text") or "")
|
||||
return out
|
||||
|
||||
|
||||
def load_autotext() -> dict:
|
||||
"""Laedt Autotext-Einstellungen. ACHTUNG: Der globale Autotext-Listener
|
||||
in basis14.py nutzt einen RAM-Cache und ruft diese Funktion NICHT im
|
||||
@@ -559,9 +574,10 @@ def load_autotext() -> dict:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
if isinstance(data, dict):
|
||||
return {
|
||||
out = {
|
||||
"enabled": data.get("enabled", True),
|
||||
"entries": data.get("entries") if isinstance(data.get("entries"), dict) else {},
|
||||
"entries": _coerce_autotext_entry_values(
|
||||
data.get("entries") if isinstance(data.get("entries"), dict) else {}),
|
||||
"diktat_auto_start": data.get("diktat_auto_start", True),
|
||||
"notizen_open_on_start": data.get("notizen_open_on_start", data.get("diktat_open_on_start", True)),
|
||||
"textbloecke_visible": data.get("textbloecke_visible", True),
|
||||
@@ -577,6 +593,10 @@ def load_autotext() -> dict:
|
||||
"textbloecke_collapsed": data.get("textbloecke_collapsed", False),
|
||||
"status_color": data.get("status_color", "#BD4500"),
|
||||
"soap_collapsed": data.get("soap_collapsed", False),
|
||||
"entry_meta": data.get("entry_meta") if isinstance(data.get("entry_meta"), dict) else {},
|
||||
"workspace_backup_ts": data.get("workspace_backup_ts"),
|
||||
"office_sidebar_textbloecke_open": data.get(
|
||||
"office_sidebar_textbloecke_open", True),
|
||||
"autoOpenNews": data.get("autoOpenNews", False),
|
||||
"autoOpenEvents": data.get("autoOpenEvents", True),
|
||||
"newsTemplate": data.get("newsTemplate", "all"),
|
||||
@@ -595,18 +615,19 @@ def load_autotext() -> dict:
|
||||
"global_right_click_paste": data.get("global_right_click_paste", True),
|
||||
"todo_auto_open": data.get("todo_auto_open", False),
|
||||
"autocopy_after_diktat": data.get("autocopy_after_diktat", True),
|
||||
"kommentare_auto_open": data.get("kommentare_auto_open", False),
|
||||
"empfang_auto_open": data.get("empfang_auto_open", False),
|
||||
"empfang_was_open": data.get("empfang_was_open", False),
|
||||
"empfang_prefs": data.get("empfang_prefs", {}),
|
||||
"medikament_quelle": data.get("medikament_quelle", "compendium.ch"),
|
||||
"diagnose_quelle": data.get("diagnose_quelle", ""),
|
||||
"dokumente_collapsed": data.get("dokumente_collapsed", False),
|
||||
"active_brief_profile": data.get("active_brief_profile", ""),
|
||||
"stilprofil_enabled": data.get("stilprofil_enabled", False),
|
||||
"stilprofil_name": data.get("stilprofil_name", ""),
|
||||
"stilprofil_default_brief": data.get("stilprofil_default_brief", False),
|
||||
"kommentare_auto_open": data.get("kommentare_auto_open", False),
|
||||
"empfang_auto_open": data.get("empfang_auto_open", False),
|
||||
"empfang_was_open": data.get("empfang_was_open", False),
|
||||
"empfang_prefs": data.get("empfang_prefs", {}),
|
||||
"medikament_quelle": data.get("medikament_quelle", "compendium.ch"),
|
||||
"diagnose_quelle": data.get("diagnose_quelle", ""),
|
||||
"dokumente_collapsed": data.get("dokumente_collapsed", False),
|
||||
"active_brief_profile": data.get("active_brief_profile", ""),
|
||||
"stilprofil_enabled": data.get("stilprofil_enabled", False),
|
||||
"stilprofil_name": data.get("stilprofil_name", ""),
|
||||
"stilprofil_default_brief": data.get("stilprofil_default_brief", False),
|
||||
}
|
||||
return out
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
@@ -624,6 +645,9 @@ def load_autotext() -> dict:
|
||||
"textbloecke_collapsed": False,
|
||||
"status_color": "#BD4500",
|
||||
"soap_collapsed": False,
|
||||
"entry_meta": {},
|
||||
"workspace_backup_ts": "",
|
||||
"office_sidebar_textbloecke_open": True,
|
||||
"dokumente_collapsed": False,
|
||||
"autoOpenNews": False,
|
||||
"autoOpenEvents": True,
|
||||
@@ -660,7 +684,7 @@ def save_autotext(data: dict) -> None:
|
||||
json.dump(
|
||||
{
|
||||
"enabled": data.get("enabled", True),
|
||||
"entries": data.get("entries") or {},
|
||||
"entries": _coerce_autotext_entry_values(data.get("entries") or {}),
|
||||
"diktat_auto_start": data.get("diktat_auto_start", True),
|
||||
"notizen_open_on_start": data.get("notizen_open_on_start", data.get("diktat_open_on_start", True)),
|
||||
"textbloecke_visible": data.get("textbloecke_visible", True),
|
||||
@@ -670,6 +694,10 @@ def save_autotext(data: dict) -> None:
|
||||
"textbloecke_collapsed": data.get("textbloecke_collapsed", False),
|
||||
"status_color": data.get("status_color", "#BD4500"),
|
||||
"soap_collapsed": data.get("soap_collapsed", False),
|
||||
"entry_meta": data.get("entry_meta") if isinstance(data.get("entry_meta"), dict) else {},
|
||||
"workspace_backup_ts": data.get("workspace_backup_ts"),
|
||||
"office_sidebar_textbloecke_open": data.get(
|
||||
"office_sidebar_textbloecke_open", True),
|
||||
"autoOpenNews": bool(data.get("autoOpenNews", False)),
|
||||
"autoOpenEvents": bool(data.get("autoOpenEvents", True)),
|
||||
"newsTemplate": data.get("newsTemplate", "all"),
|
||||
@@ -1290,7 +1318,11 @@ def load_textbloecke():
|
||||
out = {}
|
||||
for k, v in data.items():
|
||||
if isinstance(k, str) and k.isdigit() and isinstance(v, dict):
|
||||
out[k] = {"name": (v.get("name") or "").strip(), "content": v.get("content") or ""}
|
||||
out[k] = {
|
||||
"name": (v.get("name") or "").strip(),
|
||||
"content": v.get("content") or "",
|
||||
"updated_at": (v.get("updated_at") or "").strip(),
|
||||
}
|
||||
slots = sorted(out.keys(), key=int)
|
||||
if len(slots) >= 2:
|
||||
return {s: out[s] for s in slots}
|
||||
@@ -1305,7 +1337,11 @@ def save_textbloecke(data: dict) -> None:
|
||||
full = {}
|
||||
for k, v in (data or {}).items():
|
||||
if isinstance(k, str) and isinstance(v, dict):
|
||||
full[k] = {"name": (v.get("name") or "").strip(), "content": v.get("content") or ""}
|
||||
full[k] = {
|
||||
"name": (v.get("name") or "").strip(),
|
||||
"content": v.get("content") or "",
|
||||
"updated_at": (v.get("updated_at") or "").strip(),
|
||||
}
|
||||
if len(full) < 2:
|
||||
return
|
||||
with open(_textbloecke_config_path(), "w", encoding="utf-8") as f:
|
||||
|
||||
Reference in New Issue
Block a user