dynamic-settings-widget 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. dynamic_settings_widget/__init__.py +56 -0
  2. dynamic_settings_widget/adapters/__init__.py +42 -0
  3. dynamic_settings_widget/adapters/base.py +179 -0
  4. dynamic_settings_widget/adapters/memory.py +201 -0
  5. dynamic_settings_widget/adapters/runner.py +63 -0
  6. dynamic_settings_widget/core/__init__.py +1 -0
  7. dynamic_settings_widget/core/catalog.py +201 -0
  8. dynamic_settings_widget/core/common.py +214 -0
  9. dynamic_settings_widget/core/conditions.py +146 -0
  10. dynamic_settings_widget/core/datatypes.py +414 -0
  11. dynamic_settings_widget/core/diagnostics.py +69 -0
  12. dynamic_settings_widget/core/loader.py +101 -0
  13. dynamic_settings_widget/core/model.py +245 -0
  14. dynamic_settings_widget/core/overrides.py +353 -0
  15. dynamic_settings_widget/core/parser.py +552 -0
  16. dynamic_settings_widget/core/presentation.py +68 -0
  17. dynamic_settings_widget/core/registry.py +258 -0
  18. dynamic_settings_widget/core/state.py +314 -0
  19. dynamic_settings_widget/data/example_catalog.json +23 -0
  20. dynamic_settings_widget/data/example_layout.json +23 -0
  21. dynamic_settings_widget/data/settings_catalog.schema.json +388 -0
  22. dynamic_settings_widget/data/settings_definition.schema.json +1041 -0
  23. dynamic_settings_widget/data/settings_layout.schema.json +701 -0
  24. dynamic_settings_widget/data/settings_override.schema.json +406 -0
  25. dynamic_settings_widget/py.typed +0 -0
  26. dynamic_settings_widget/session.py +1537 -0
  27. dynamic_settings_widget/standalone/__init__.py +67 -0
  28. dynamic_settings_widget/standalone/action_button.py +200 -0
  29. dynamic_settings_widget/standalone/auth_widget.py +377 -0
  30. dynamic_settings_widget/standalone/check_box_editor.py +233 -0
  31. dynamic_settings_widget/standalone/choice_buttons_editor.py +394 -0
  32. dynamic_settings_widget/standalone/color_editor.py +316 -0
  33. dynamic_settings_widget/standalone/dropdown_editor.py +356 -0
  34. dynamic_settings_widget/standalone/editable_label.py +428 -0
  35. dynamic_settings_widget/standalone/float_spin_box.py +621 -0
  36. dynamic_settings_widget/standalone/font_editor.py +348 -0
  37. dynamic_settings_widget/standalone/hotkey_editor.py +681 -0
  38. dynamic_settings_widget/standalone/info_label.py +190 -0
  39. dynamic_settings_widget/standalone/int_spin_box.py +627 -0
  40. dynamic_settings_widget/standalone/multi_choice_editor.py +428 -0
  41. dynamic_settings_widget/standalone/password_editor.py +348 -0
  42. dynamic_settings_widget/standalone/path_editor.py +615 -0
  43. dynamic_settings_widget/standalone/protected_group_box.py +287 -0
  44. dynamic_settings_widget/standalone/server_connection_editor.py +642 -0
  45. dynamic_settings_widget/standalone/slider_spin_box.py +840 -0
  46. dynamic_settings_widget/standalone/sound_selection_widget.py +710 -0
  47. dynamic_settings_widget/standalone/status_label.py +148 -0
  48. dynamic_settings_widget/standalone/switch_editor.py +293 -0
  49. dynamic_settings_widget/standalone/text_editor.py +265 -0
  50. dynamic_settings_widget/testlab/__init__.py +1 -0
  51. dynamic_settings_widget/testlab/__main__.py +5 -0
  52. dynamic_settings_widget/testlab/app.py +699 -0
  53. dynamic_settings_widget/testlab/assets/extra_sounds/Signal.wav +0 -0
  54. dynamic_settings_widget/testlab/assets/sounds/Benachrichtigung.wav +0 -0
  55. dynamic_settings_widget/testlab/assets/sounds/feedback/Signal.wav +0 -0
  56. dynamic_settings_widget/testlab/definitions/broken_base.json +25 -0
  57. dynamic_settings_widget/testlab/definitions/demo.json +634 -0
  58. dynamic_settings_widget/testlab/definitions/gallery.json +255 -0
  59. dynamic_settings_widget/testlab/definitions/override_example.json +41 -0
  60. dynamic_settings_widget/testlab/definitions/override_invalid.json +11 -0
  61. dynamic_settings_widget/testlab/definitions/override_syntax_error.json +5 -0
  62. dynamic_settings_widget/testlab/definitions/override_weaken.json +10 -0
  63. dynamic_settings_widget/testlab/definitions/voice_v2/01_left_top.json +1190 -0
  64. dynamic_settings_widget/testlab/definitions/voice_v2/catalog.json +1930 -0
  65. dynamic_settings_widget/testlab/definitions/voice_v2/models.json +141 -0
  66. dynamic_settings_widget/testlab/definitions/voice_v2/wakewords.json +161 -0
  67. dynamic_settings_widget/testlab/dummy.py +353 -0
  68. dynamic_settings_widget/testlab/extensions.py +149 -0
  69. dynamic_settings_widget/testlab/gallery.py +223 -0
  70. dynamic_settings_widget/testlab/http_adapter.py +430 -0
  71. dynamic_settings_widget/testlab/http_server.py +493 -0
  72. dynamic_settings_widget/testlab/voice_v2.py +251 -0
  73. dynamic_settings_widget/ui/__init__.py +23 -0
  74. dynamic_settings_widget/ui/base.py +63 -0
  75. dynamic_settings_widget/ui/builders.py +226 -0
  76. dynamic_settings_widget/ui/containers.py +441 -0
  77. dynamic_settings_widget/ui/dialog.py +231 -0
  78. dynamic_settings_widget/ui/editing.py +51 -0
  79. dynamic_settings_widget/ui/row.py +810 -0
  80. dynamic_settings_widget/ui/view.py +248 -0
  81. dynamic_settings_widget/widgets/__init__.py +74 -0
  82. dynamic_settings_widget/widgets/base.py +145 -0
  83. dynamic_settings_widget/widgets/bridge.py +222 -0
  84. dynamic_settings_widget/widgets/theme.py +107 -0
  85. dynamic_settings_widget-2.0.0.dist-info/METADATA +237 -0
  86. dynamic_settings_widget-2.0.0.dist-info/RECORD +90 -0
  87. dynamic_settings_widget-2.0.0.dist-info/WHEEL +5 -0
  88. dynamic_settings_widget-2.0.0.dist-info/entry_points.txt +5 -0
  89. dynamic_settings_widget-2.0.0.dist-info/licenses/LICENSE +21 -0
  90. dynamic_settings_widget-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,141 @@
1
+ [
2
+ {
3
+ "id": "faster-whisper-tiny",
4
+ "engine": "faster_whisper",
5
+ "model": "tiny"
6
+ },
7
+ {
8
+ "id": "faster-whisper-tiny.en",
9
+ "engine": "faster_whisper",
10
+ "model": "tiny.en"
11
+ },
12
+ {
13
+ "id": "faster-whisper-base",
14
+ "engine": "faster_whisper",
15
+ "model": "base"
16
+ },
17
+ {
18
+ "id": "faster-whisper-base.en",
19
+ "engine": "faster_whisper",
20
+ "model": "base.en"
21
+ },
22
+ {
23
+ "id": "faster-whisper-small",
24
+ "engine": "faster_whisper",
25
+ "model": "small"
26
+ },
27
+ {
28
+ "id": "faster-whisper-small.en",
29
+ "engine": "faster_whisper",
30
+ "model": "small.en"
31
+ },
32
+ {
33
+ "id": "faster-whisper-medium",
34
+ "engine": "faster_whisper",
35
+ "model": "medium"
36
+ },
37
+ {
38
+ "id": "faster-whisper-medium.en",
39
+ "engine": "faster_whisper",
40
+ "model": "medium.en"
41
+ },
42
+ {
43
+ "id": "faster-whisper-large-v2",
44
+ "engine": "faster_whisper",
45
+ "model": "large-v2"
46
+ },
47
+ {
48
+ "id": "faster-whisper-large-v3",
49
+ "engine": "faster_whisper",
50
+ "model": "large-v3"
51
+ },
52
+ {
53
+ "id": "faster-whisper-large-v3-turbo",
54
+ "engine": "faster_whisper",
55
+ "model": "large-v3-turbo"
56
+ },
57
+ {
58
+ "id": "kroko-de-community-64-l",
59
+ "engine": "kroko_onnx",
60
+ "model": "Kroko-DE-Community-64-L-Streaming-001.data",
61
+ "tier": "community",
62
+ "language": "de"
63
+ },
64
+ {
65
+ "id": "kroko-de-community-128-l",
66
+ "engine": "kroko_onnx",
67
+ "model": "Kroko-DE-Community-128-L-Streaming-001.data",
68
+ "tier": "community",
69
+ "language": "de"
70
+ },
71
+ {
72
+ "id": "kroko-en-community-64-l",
73
+ "engine": "kroko_onnx",
74
+ "model": "Kroko-EN-Community-64-L-Streaming-001.data",
75
+ "tier": "community",
76
+ "language": "en"
77
+ },
78
+ {
79
+ "id": "kroko-en-community-128-l",
80
+ "engine": "kroko_onnx",
81
+ "model": "Kroko-EN-Community-128-L-Streaming-001.data",
82
+ "tier": "community",
83
+ "language": "en"
84
+ },
85
+ {
86
+ "id": "kroko-de-pro-16-m",
87
+ "engine": "kroko_onnx",
88
+ "model": "Kroko-DE-Pro-16-M-Streaming-001.data",
89
+ "tier": "pro",
90
+ "language": "de"
91
+ },
92
+ {
93
+ "id": "kroko-de-pro-16-l",
94
+ "engine": "kroko_onnx",
95
+ "model": "Kroko-DE-Pro-16-L-Streaming-001.data",
96
+ "tier": "pro",
97
+ "language": "de"
98
+ },
99
+ {
100
+ "id": "kroko-de-pro-32-m",
101
+ "engine": "kroko_onnx",
102
+ "model": "Kroko-DE-Pro-32-M-Streaming-001.data",
103
+ "tier": "pro",
104
+ "language": "de"
105
+ },
106
+ {
107
+ "id": "kroko-de-pro-32-l",
108
+ "engine": "kroko_onnx",
109
+ "model": "Kroko-DE-Pro-32-L-Streaming-001.data",
110
+ "tier": "pro",
111
+ "language": "de"
112
+ },
113
+ {
114
+ "id": "kroko-de-pro-64-m",
115
+ "engine": "kroko_onnx",
116
+ "model": "Kroko-DE-Pro-64-M-Streaming-001.data",
117
+ "tier": "pro",
118
+ "language": "de"
119
+ },
120
+ {
121
+ "id": "kroko-de-pro-64-l",
122
+ "engine": "kroko_onnx",
123
+ "model": "Kroko-DE-Pro-64-L-Streaming-001.data",
124
+ "tier": "pro",
125
+ "language": "de"
126
+ },
127
+ {
128
+ "id": "kroko-de-pro-128-m",
129
+ "engine": "kroko_onnx",
130
+ "model": "Kroko-DE-Pro-128-M-Streaming-001.data",
131
+ "tier": "pro",
132
+ "language": "de"
133
+ },
134
+ {
135
+ "id": "kroko-de-pro-128-l",
136
+ "engine": "kroko_onnx",
137
+ "model": "Kroko-DE-Pro-128-L-Streaming-001.data",
138
+ "tier": "pro",
139
+ "language": "de"
140
+ }
141
+ ]
@@ -0,0 +1,161 @@
1
+ [
2
+ {
3
+ "id": "alexa",
4
+ "displayName": "Alexa",
5
+ "aliases": []
6
+ },
7
+ {
8
+ "id": "alice",
9
+ "displayName": "Alice",
10
+ "aliases": []
11
+ },
12
+ {
13
+ "id": "computer",
14
+ "displayName": "Computer",
15
+ "aliases": []
16
+ },
17
+ {
18
+ "id": "hey_alfred",
19
+ "displayName": "Hey Alfred",
20
+ "aliases": [
21
+ "alfred"
22
+ ]
23
+ },
24
+ {
25
+ "id": "hey_billy",
26
+ "displayName": "Hey Billy",
27
+ "aliases": [
28
+ "billy"
29
+ ]
30
+ },
31
+ {
32
+ "id": "hey_bro",
33
+ "displayName": "Hey Bro",
34
+ "aliases": [
35
+ "bro"
36
+ ]
37
+ },
38
+ {
39
+ "id": "hey_glados",
40
+ "displayName": "Hey GLaDOS",
41
+ "aliases": [
42
+ "glados"
43
+ ]
44
+ },
45
+ {
46
+ "id": "hey_hermes",
47
+ "displayName": "Hey Hermes",
48
+ "aliases": [
49
+ "hermes"
50
+ ]
51
+ },
52
+ {
53
+ "id": "hey_jarvis",
54
+ "displayName": "Hey Jarvis",
55
+ "aliases": [
56
+ "jarvis"
57
+ ]
58
+ },
59
+ {
60
+ "id": "hey_lucy",
61
+ "displayName": "Hey Lucy",
62
+ "aliases": [
63
+ "lucy"
64
+ ]
65
+ },
66
+ {
67
+ "id": "hey_luna",
68
+ "displayName": "Hey Luna",
69
+ "aliases": [
70
+ "luna"
71
+ ]
72
+ },
73
+ {
74
+ "id": "hey_max",
75
+ "displayName": "Hey Max",
76
+ "aliases": [
77
+ "max"
78
+ ]
79
+ },
80
+ {
81
+ "id": "hey_mira",
82
+ "displayName": "Hey Mira",
83
+ "aliases": [
84
+ "mira"
85
+ ]
86
+ },
87
+ {
88
+ "id": "hey_mycroft",
89
+ "displayName": "Hey Mycroft",
90
+ "aliases": [
91
+ "mycroft"
92
+ ]
93
+ },
94
+ {
95
+ "id": "hey_nabu",
96
+ "displayName": "Hey Nabu",
97
+ "aliases": [
98
+ "nabu"
99
+ ]
100
+ },
101
+ {
102
+ "id": "hey_nexus",
103
+ "displayName": "Hey Nexus",
104
+ "aliases": [
105
+ "nexus"
106
+ ]
107
+ },
108
+ {
109
+ "id": "hey_nova",
110
+ "displayName": "Hey Nova",
111
+ "aliases": [
112
+ "nova"
113
+ ]
114
+ },
115
+ {
116
+ "id": "hey_oracle",
117
+ "displayName": "Hey Oracle",
118
+ "aliases": [
119
+ "oracle"
120
+ ]
121
+ },
122
+ {
123
+ "id": "hey_rhasspy",
124
+ "displayName": "Hey Rhasspy",
125
+ "aliases": [
126
+ "rhasspy"
127
+ ]
128
+ },
129
+ {
130
+ "id": "hey_rocky",
131
+ "displayName": "Hey Rocky",
132
+ "aliases": [
133
+ "rocky"
134
+ ]
135
+ },
136
+ {
137
+ "id": "ivy",
138
+ "displayName": "Ivy",
139
+ "aliases": []
140
+ },
141
+ {
142
+ "id": "pico",
143
+ "displayName": "Pico",
144
+ "aliases": []
145
+ },
146
+ {
147
+ "id": "stop",
148
+ "displayName": "Stop",
149
+ "aliases": []
150
+ },
151
+ {
152
+ "id": "timer",
153
+ "displayName": "Timer",
154
+ "aliases": []
155
+ },
156
+ {
157
+ "id": "weather",
158
+ "displayName": "Weather",
159
+ "aliases": []
160
+ }
161
+ ]
@@ -0,0 +1,353 @@
1
+ """In-Memory-Dummy: deterministische Simulation ohne Netzwerk.
2
+
3
+ Alle Zugangsdaten hier sind eindeutig gekennzeichnete Dummy-Werte ohne Wirkung
4
+ außerhalb des TestLabs.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import threading
11
+ import time
12
+ from collections.abc import Mapping, Sequence
13
+ from dataclasses import dataclass
14
+ from typing import Any
15
+
16
+ from .. import (
17
+ ActionResult,
18
+ AdapterDescription,
19
+ AdapterUnavailable,
20
+ AuthResult,
21
+ KeyMeta,
22
+ MemoryAdapter,
23
+ MemoryParameter,
24
+ OutcomeUnknown,
25
+ SecretValue,
26
+ StatusChanged,
27
+ ValueReport,
28
+ WriteRequest,
29
+ WriteResult,
30
+ WriteStatus,
31
+ )
32
+
33
+ #: Dummy-Schlüssel der Dummy-Anbindung – nur für das TestLab.
34
+ DUMMY_LOCAL_KEY = "dummy-local"
35
+ DUMMY_INNER_KEY = "dummy-inner"
36
+
37
+ WRITE_MODES = {
38
+ "normal": "Normal",
39
+ "reject": "Ablehnen",
40
+ "unavailable": "Verbindungsstörung",
41
+ "unknown": "Unklarer Ausgang (wird ausgeführt)",
42
+ "lost": "Unklarer Ausgang (wird nicht ausgeführt)",
43
+ "conflict": "Konflikt (Fremdänderung)",
44
+ "partial": "Teilfehler (jede zweite Änderung)",
45
+ "crash": "Unerwarteter Adapterfehler",
46
+ }
47
+
48
+
49
+ @dataclass
50
+ class Scenario:
51
+ """Steuerbare Simulation."""
52
+
53
+ latency: float = 0.25
54
+ write_mode: str = "normal"
55
+ auth_mode: str = "normal" # normal | deny | error
56
+ offline: bool = False
57
+ effect_delay: float | None = None # None: nur manuell wirksam machen
58
+
59
+
60
+ class DummyAdapter(MemoryAdapter):
61
+ def __init__(self, name: str = "memory", parameters: Mapping[str, MemoryParameter] | None = None) -> None:
62
+ super().__init__(
63
+ name,
64
+ parameters if parameters is not None else demo_parameters(),
65
+ choices={
66
+ "audio_devices": [
67
+ {"value": "default", "label": "Standardgerät"},
68
+ {"value": "mic-1", "label": "Simuliertes Mikrofon 1"},
69
+ {"value": "mic-2", "label": "Simuliertes Headset"},
70
+ ],
71
+ "sounds": [
72
+ {"value": "start", "label": "Beginn der Aufnahme"},
73
+ {"value": "stop", "label": "Ende der Aufnahme"},
74
+ {"value": "error", "label": "Fehler"},
75
+ {"value": "done", "label": "Text eingefügt"},
76
+ ],
77
+ "used_hotkeys": [
78
+ {"value": "Ctrl+Alt+Space", "label": "Simulierte andere Anwendung"},
79
+ {"value": "Ctrl+Shift+Space", "label": "Simulierter Passwortmanager"},
80
+ ],
81
+ "led_effects": [
82
+ {"value": "off", "label": "Kein Effekt"},
83
+ {"value": "solid", "label": "Dauerlicht"},
84
+ {"value": "blink", "label": "Blinken"},
85
+ {"value": "pulse", "label": "Pulsieren"},
86
+ ],
87
+ # Simuliert das Ergebnis eines Ordnerscans – es wird kein Dateisystem gelesen.
88
+ "sound_files": [
89
+ {"value": "", "label": "Kein Ton"},
90
+ {"value": "klick.wav", "label": "klick.wav"},
91
+ {"value": "gong.wav", "label": "gong.wav"},
92
+ {"value": "hinweis.ogg", "label": "hinweis.ogg"},
93
+ ],
94
+ "endpoints": [
95
+ {"value": "/api/v1", "label": "API Version 1"},
96
+ {"value": "/api/v2", "label": "API Version 2 (Vorschau)"},
97
+ ],
98
+ },
99
+ actions={
100
+ "mic_test": self._mic_test,
101
+ "clear_history": lambda p: ActionResult(True, "Verlauf geleert (simuliert)"),
102
+ "activate": self._activate,
103
+ "fail": lambda p: ActionResult(False, "Simulierter Fehlschlag"),
104
+ "protected_task": self._protected_task,
105
+ "connection_test": self._connection_test,
106
+ "connection_apply": self._connection_apply,
107
+ },
108
+ check_credentials=self._check,
109
+ )
110
+ self.scenario = Scenario()
111
+ self._closed = threading.Event()
112
+ self._timers: list[threading.Timer] = []
113
+
114
+ # -- Simulation -----------------------------------------------------------------------
115
+ def _wait(self) -> None:
116
+ if self.scenario.latency > 0:
117
+ self._closed.wait(self.scenario.latency)
118
+
119
+ def _require_online(self) -> None:
120
+ if self.scenario.offline:
121
+ raise AdapterUnavailable("Simulierte Verbindungsstörung")
122
+
123
+ def set_offline(self, offline: bool) -> None:
124
+ self.scenario.offline = offline
125
+ self.emit(StatusChanged("offline" if offline else "online", "Simulierte Störung" if offline else ""))
126
+
127
+ def start(self) -> None:
128
+ self._closed.clear()
129
+
130
+ def close(self) -> None:
131
+ self._closed.set()
132
+ for timer in self._timers:
133
+ timer.cancel()
134
+ self._timers.clear()
135
+
136
+ # -- Operationen ------------------------------------------------------------------------
137
+ def describe(self) -> AdapterDescription:
138
+ self._wait()
139
+ self._require_online()
140
+ return super().describe()
141
+
142
+ def read(self, keys: Sequence[str]) -> list[ValueReport]:
143
+ self._wait()
144
+ self._require_online()
145
+ return super().read(keys)
146
+
147
+ def write(self, changes: Sequence[WriteRequest]) -> list[WriteResult]:
148
+ mode = self.scenario.write_mode
149
+ self._wait()
150
+ self._require_online()
151
+ return self._simulate_write(changes, mode)
152
+
153
+ def _simulate_write(self, changes: Sequence[WriteRequest], mode: str) -> list[WriteResult]:
154
+ if mode == "unavailable":
155
+ raise AdapterUnavailable("Simulierte Verbindungsstörung")
156
+ if mode == "crash":
157
+ raise RuntimeError("Simulierter interner Fehler")
158
+ if mode == "lost":
159
+ raise OutcomeUnknown("Simulierte Zeitüberschreitung")
160
+ if mode == "reject":
161
+ return [WriteResult(c.key, WriteStatus.REJECTED, "Simulierte Ablehnung", self._safe_report(c.key)) for c in changes]
162
+ if mode == "conflict":
163
+ with self.lock:
164
+ for change in changes:
165
+ if change.key in self.parameters:
166
+ self.parameters[change.key].revision += 1
167
+ results = super().write(changes)
168
+ if mode == "partial":
169
+ results = [
170
+ WriteResult(r.key, WriteStatus.REJECTED, "Simulierter Teilfehler", self._safe_report(r.key)) if i % 2 else r
171
+ for i, r in enumerate(results)
172
+ ]
173
+ if mode == "unknown":
174
+ raise OutcomeUnknown("Simulierte Zeitüberschreitung nach Ausführung")
175
+ pending = [r.key for r in results if r.status is WriteStatus.PENDING]
176
+ if pending and self.scenario.effect_delay is not None:
177
+ timer = threading.Timer(self.scenario.effect_delay, lambda: self.activate(pending))
178
+ timer.daemon = True
179
+ self._timers.append(timer)
180
+ timer.start()
181
+ return results
182
+
183
+ def _safe_report(self, key: str) -> ValueReport:
184
+ with self.lock:
185
+ return self.report(key)
186
+
187
+ def invoke(self, action: str, params: Mapping[str, Any]) -> ActionResult:
188
+ self._wait()
189
+ self._require_online()
190
+ return super().invoke(action, params)
191
+
192
+ def authenticate(self, scope: str, credentials: Mapping[str, SecretValue]) -> AuthResult:
193
+ self._wait()
194
+ self._require_online()
195
+ if self.scenario.auth_mode == "error":
196
+ raise AdapterUnavailable("Prüfstelle nicht erreichbar (simuliert)")
197
+ if self.scenario.auth_mode == "deny":
198
+ return AuthResult(False, "Simulierte Ablehnung")
199
+ return super().authenticate(scope, credentials)
200
+
201
+ # -- Dummy-Logik -------------------------------------------------------------------------
202
+ @staticmethod
203
+ def _check(scope: str, credentials: Mapping[str, SecretValue]) -> bool:
204
+ expected = {"local_admin": DUMMY_LOCAL_KEY, "inner": DUMMY_INNER_KEY}.get(scope)
205
+ key = credentials.get("key")
206
+ return expected is not None and key is not None and key == SecretValue(expected)
207
+
208
+ def _mic_test(self, params: Mapping[str, Any]) -> ActionResult:
209
+ time.sleep(0.3)
210
+ return ActionResult(
211
+ True,
212
+ f"Simulierter Mikrofontest: Gerät „{params.get('device')}“, Verstärkung {params.get('gain')} dB",
213
+ {"pegel": 42},
214
+ )
215
+
216
+ def _activate(self, params: Mapping[str, Any]) -> ActionResult:
217
+ changed = self.activate()
218
+ return ActionResult(True, f"{len(changed)} ausstehende Werte wirksam" if changed else "Nichts ausstehend")
219
+
220
+ def _protected_task(self, params: Mapping[str, Any]) -> ActionResult:
221
+ if not self.has_permission("local_admin"):
222
+ return ActionResult(False, "Adapter: Berechtigung „local_admin“ fehlt")
223
+ return ActionResult(True, "Geschützte Aktion ausgeführt (simuliert)")
224
+
225
+ def _connection_test(self, params: Mapping[str, Any]) -> ActionResult:
226
+ address = str(params.get("address", ""))
227
+ if "fail" in address or self.scenario.write_mode == "unavailable":
228
+ return ActionResult(False, "Gegenstelle antwortet nicht (simuliert)")
229
+ return ActionResult(True, f"{params.get('url')} erreichbar (simuliert)")
230
+
231
+ def _connection_apply(self, params: Mapping[str, Any]) -> ActionResult:
232
+ value = params["value"]
233
+ if "fail" in value["address"]:
234
+ return ActionResult(False, "Verbindung abgelehnt (simuliert)")
235
+ with self.lock:
236
+ parameter = self.parameters["gallery.connection"]
237
+ parameter.value = dict(value)
238
+ parameter.revision += 1
239
+ return ActionResult(True, f"Verbunden mit {value['address']} (simuliert)")
240
+
241
+
242
+ def _p(datatype: str, value: Any, *, deferred: str = "", permission: str | None = None, writable: bool = True,
243
+ default: Any = None, choices_list: str | None = None, **constraints: Any) -> MemoryParameter: # fmt: skip
244
+ from .. import UNSET
245
+
246
+ return MemoryParameter(
247
+ KeyMeta(
248
+ datatype,
249
+ writable=writable,
250
+ permission=permission,
251
+ constraints=constraints,
252
+ choices_list=choices_list,
253
+ default=UNSET if default is None else default,
254
+ ),
255
+ value,
256
+ deferred=bool(deferred),
257
+ effective_from=deferred,
258
+ )
259
+
260
+
261
+ _ROOT = os.path.abspath(os.sep) # Laufwerkswurzel bzw. „/“ – neutral, ohne Benutzerdaten
262
+
263
+
264
+ def demo_parameters() -> dict[str, MemoryParameter]:
265
+ """Kontrollierte Testdaten für Demo und Galerie."""
266
+ next_time = "ab der nächsten Aktivierung"
267
+ return {
268
+ # Demo
269
+ "hotkey.primary": _p("hotkey", "Ctrl+Alt+R", optional=False),
270
+ "hotkey.secondary": _p("hotkey", None, optional=True),
271
+ "clipboard.restore": _p("bool", True, default=True),
272
+ "clipboard.delay": _p("int", 250, default=250, min=0, max=5000),
273
+ "ui.language": _p("choice", "de", choices=["de", "en", "fr"]),
274
+ "audio.device": _p("choice", "default", choices_list="audio_devices"),
275
+ "audio.gain": _p("float", 0.0, deferred=next_time, default=0.0, min=-20, max=20),
276
+ "audio.sample_rate": _p("int", 16000, writable=False),
277
+ "audio.notification_sound": _p("string", "bundled:Benachrichtigung.wav", optional=True),
278
+ "audio.noise_gate": _p("bool", False),
279
+ "audio.auto_gain": _p("bool", True),
280
+ "appearance.theme": _p("choice", "system", choices=["system", "light", "dark"]),
281
+ "appearance.accent": _p("color", "#1F6FEB", default="#1F6FEB"),
282
+ "appearance.font": _p("font", None, optional=True),
283
+ "appearance.font_size": _p("int", 10, default=10, min=6, max=32),
284
+ "appearance.opacity": _p("float", 0.95, min=0.2, max=1.0),
285
+ "feedback.led": _p("bool", False),
286
+ "feedback.led_brightness": _p("int", 60, default=60, min=0, max=100),
287
+ "feedback.led_color": _p("color", "#00AA55"),
288
+ "feedback.sounds": _p("multi_choice", ["start", "stop"], choices_list="sounds"),
289
+ "feedback.rating": _p("int", 3, min=0, max=5),
290
+ # Machbarkeitsdemo ereignisbezogener Rückmeldung (generisch, ohne LED-/Audio-Fachlogik)
291
+ "feedback.event.start.effect": _p("choice", "pulse", choices_list="led_effects"),
292
+ "feedback.event.start.color": _p("color", "#1F6FEB"),
293
+ "feedback.event.start.speed": _p("int", 60, min=10, max=100),
294
+ "feedback.event.start.sound": _p("choice", "klick.wav", choices_list="sound_files"),
295
+ "feedback.event.stop.effect": _p("choice", "off", choices_list="led_effects"),
296
+ "feedback.event.stop.color": _p("color", "#1A7A37"),
297
+ "feedback.event.stop.speed": _p("int", 40, min=10, max=100),
298
+ "feedback.event.stop.sound": _p("choice", "", choices_list="sound_files"),
299
+ "history.enabled": _p("bool", True),
300
+ "history.days": _p("int", 30, optional=True, min=1, max=365),
301
+ "history.export_path": _p("path", "", optional=False),
302
+ "diagnostics.level": _p("choice", "info", choices=["debug", "info", "warning", "error"]),
303
+ "diagnostics.notes": _p("string", "Testnotiz", max_length=500),
304
+ "client.local_key": _p("secret", SecretValue("dummy-gespeichert"), optional=True),
305
+ # Galerie
306
+ "gallery.text": _p("string", "Beispieltext", max_length=60),
307
+ "gallery.editable": _p("string", "Profil Büro", max_length=40),
308
+ "gallery.multiline": _p("string", "Erste Zeile\nZweite Zeile"),
309
+ "gallery.password": _p("secret", SecretValue("dummy-geheim"), optional=True),
310
+ "gallery.int": _p("int", 5, min=0, max=10, default=5),
311
+ "gallery.float": _p("float", 1.25, min=0, max=10),
312
+ "gallery.int_inline": _p("int", 4, min=1, max=16),
313
+ "gallery.slider_inline": _p("int", 70, min=0, max=100),
314
+ "gallery.slider_int": _p("int", 40, min=0, max=100),
315
+ "gallery.slider_float": _p("float", 0.333, min=0, max=1),
316
+ "gallery.optional_int": _p("int", None, optional=True, min=-5, max=5),
317
+ "gallery.hotkey": _p("hotkey", "Ctrl+Alt+K", optional=True),
318
+ "gallery.checkbox": _p("bool", True),
319
+ "gallery.switch": _p("bool", False),
320
+ "gallery.dropdown": _p("choice", "b", choices=["a", "b", "c"]),
321
+ "gallery.dynamic": _p("choice", "mic-1", choices_list="audio_devices"),
322
+ "gallery.buttons": _p("choice", 2, choices=[1, 2, 3]),
323
+ "gallery.multi": _p("multi_choice", ["start"], choices_list="sounds"),
324
+ "gallery.multi_long": _p("multi_choice", ["Wort 3", "Wort 7"]),
325
+ "gallery.color": _p("color", "#336699"),
326
+ "gallery.color_alpha": _p("color", "#80336699", alpha=True),
327
+ "gallery.font": _p("font", None, optional=True),
328
+ "gallery.font_required": _p("font", "Arial"),
329
+ "gallery.sound_manual": _p("string", "bundled:Benachrichtigung.wav", optional=True),
330
+ "gallery.sound_auto": _p("string", None, optional=True),
331
+ "gallery.sound_missing": _p("string", "bundled:fehlt.wav", optional=True),
332
+ "gallery.path": _p("path", ""),
333
+ "gallery.directory": _p("path", ""),
334
+ # Pfadprüfung: Laufwerkswurzel existiert; die anderen Pfade bewusst nicht (es wird nichts angelegt).
335
+ "gallery.path_checked": _p("path", os.path.join(_ROOT, "gibt_es_nicht.txt")),
336
+ "gallery.save_path": _p("path", os.path.join(_ROOT, "kein_solcher_ordner", "export.csv")),
337
+ "gallery.directory_checked": _p("path", _ROOT),
338
+ "gallery.rating": _p("int", 4, min=0, max=5),
339
+ "gallery.read_only": _p("string", "Nur lesbar", writable=False),
340
+ "gallery.deferred": _p("int", 5, deferred=next_time, default=5, min=0, max=10),
341
+ "gallery.immediate": _p("bool", False),
342
+ "gallery.protected": _p("int", 7, permission="local_admin", min=0, max=10),
343
+ "gallery.inner": _p("string", "Innerer Wert", permission="inner"),
344
+ "gallery.external": _p("string", "Extern freigegeben", permission="operator"),
345
+ "gallery.hidden": _p("string", "Verborgen bis zur Freigabe", permission="local_admin"),
346
+ "gallery.readable": _p("string", "Vor Freigabe lesbar", permission="local_admin"),
347
+ "gallery.connection": _p("connection", {"address": "localhost:8765", "endpoint": "/api/v1"}),
348
+ "gallery.extra_compatible": _p("float", 0.5, min=0, max=1),
349
+ "gallery.extra_unsupported": _p("matrix", [[1, 0], [0, 1]]),
350
+ }
351
+
352
+
353
+ __all__ = ["DUMMY_INNER_KEY", "DUMMY_LOCAL_KEY", "DummyAdapter", "Scenario", "WRITE_MODES", "demo_parameters"]