omnipython-applibs 0.1.2__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.
- appkit/__init__.py +52 -0
- appkit/__init__.pyi +17 -0
- appkit/data.py +149 -0
- appkit/data.pyi +25 -0
- appkit/foreground.py +357 -0
- appkit/foreground.pyi +45 -0
- appkit/home.py +19 -0
- appkit/home.pyi +8 -0
- appkit/hover.py +59 -0
- appkit/hover.pyi +13 -0
- appkit/index.py +199 -0
- appkit/index.pyi +30 -0
- appkit/launcher.py +1075 -0
- appkit/launcher.pyi +96 -0
- appkit/manifest.py +75 -0
- appkit/manifest.pyi +8 -0
- appkit/net.py +167 -0
- appkit/net.pyi +34 -0
- appkit/places.py +202 -0
- appkit/places.pyi +39 -0
- appkit/py.typed +0 -0
- appkit/scope.py +636 -0
- appkit/scope.pyi +110 -0
- appkit/shell.py +121 -0
- appkit/shell.pyi +32 -0
- appkit/worker.py +409 -0
- appkit/worker.pyi +83 -0
- controlkit/__init__.py +19 -0
- controlkit/__init__.pyi +10 -0
- controlkit/_draw.py +88 -0
- controlkit/_safe.py +29 -0
- controlkit/dotmatrix.py +101 -0
- controlkit/dotmatrix.pyi +23 -0
- controlkit/encoder.py +297 -0
- controlkit/encoder.pyi +55 -0
- controlkit/font5x7.py +22 -0
- controlkit/font5x7.pyi +11 -0
- controlkit/lamp_button.py +92 -0
- controlkit/lamp_button.pyi +40 -0
- controlkit/meter.py +86 -0
- controlkit/meter.pyi +30 -0
- controlkit/mock.py +116 -0
- controlkit/mock.pyi +35 -0
- controlkit/pad_grid.py +113 -0
- controlkit/pad_grid.pyi +41 -0
- controlkit/py.typed +0 -0
- controlkit/slider.py +185 -0
- controlkit/slider.pyi +49 -0
- controlkit/sprites.py +279 -0
- controlkit/sprites.pyi +22 -0
- controlkit/theme.py +120 -0
- controlkit/theme.pyi +15 -0
- deskkit/__init__.py +74 -0
- deskkit/__init__.pyi +18 -0
- deskkit/forecast.py +261 -0
- deskkit/forecast.pyi +40 -0
- deskkit/localtime.py +215 -0
- deskkit/localtime.pyi +33 -0
- deskkit/py.typed +0 -0
- deskkit/shell.py +113 -0
- deskkit/shell.pyi +33 -0
- omnipython_applibs-0.1.2.dist-info/METADATA +90 -0
- omnipython_applibs-0.1.2.dist-info/RECORD +143 -0
- omnipython_applibs-0.1.2.dist-info/WHEEL +5 -0
- omnipython_applibs-0.1.2.dist-info/licenses/LICENSE +21 -0
- omnipython_applibs-0.1.2.dist-info/top_level.txt +9 -0
- programkit/__init__.py +27 -0
- programkit/__init__.pyi +8 -0
- programkit/board.py +56 -0
- programkit/board.pyi +20 -0
- programkit/press.py +63 -0
- programkit/press.pyi +17 -0
- programkit/py.typed +0 -0
- programkit/rows.py +149 -0
- programkit/rows.pyi +34 -0
- sayso/__init__.py +109 -0
- sayso/__init__.pyi +124 -0
- sayso/auth.py +811 -0
- sayso/auth.pyi +102 -0
- sayso/client.py +1286 -0
- sayso/client.pyi +138 -0
- sayso/keepalive.py +371 -0
- sayso/keepalive.pyi +53 -0
- sayso/local.py +85 -0
- sayso/local.pyi +28 -0
- sayso/object_specs.py +706 -0
- sayso/object_specs.pyi +8 -0
- sayso/objects.py +411 -0
- sayso/objects.pyi +854 -0
- sayso/py.typed +0 -0
- sayso/schema_coverage.py +210 -0
- sayso/schema_coverage.pyi +13 -0
- sayso/transport.py +426 -0
- sayso/transport.pyi +47 -0
- songmodel/__init__.py +30 -0
- songmodel/__init__.pyi +9 -0
- songmodel/link.py +189 -0
- songmodel/link.pyi +53 -0
- songmodel/model.py +238 -0
- songmodel/model.pyi +40 -0
- songmodel/page.html +225 -0
- songmodel/page_data.py +236 -0
- songmodel/page_data.pyi +6 -0
- songmodel/py.typed +0 -0
- soundmodule/__init__.py +7 -0
- soundmodule/__init__.pyi +6 -0
- soundmodule/engine.py +1001 -0
- soundmodule/engine.pyi +196 -0
- soundmodule/names.py +298 -0
- soundmodule/names.pyi +30 -0
- soundmodule/pipes.py +105 -0
- soundmodule/pipes.pyi +31 -0
- soundmodule/py.typed +0 -0
- soundmodule/run.py +249 -0
- soundmodule/run.pyi +49 -0
- spectrum/__init__.py +72 -0
- spectrum/__init__.pyi +30 -0
- spectrum/analyzer.py +231 -0
- spectrum/analyzer.pyi +67 -0
- spectrum/fake_music.py +201 -0
- spectrum/fake_music.pyi +36 -0
- spectrum/pump_levels.py +126 -0
- spectrum/pump_levels.pyi +46 -0
- spectrum/py.typed +0 -0
- spectrum/spectrum_view.py +403 -0
- spectrum/spectrum_view.pyi +80 -0
- touchkit/__init__.py +4 -0
- touchkit/__init__.pyi +4 -0
- touchkit/cam.py +146 -0
- touchkit/cam.pyi +35 -0
- touchkit/clock.py +18 -0
- touchkit/clock.pyi +6 -0
- touchkit/ecp.py +134 -0
- touchkit/ecp.pyi +28 -0
- touchkit/net.py +347 -0
- touchkit/net.pyi +27 -0
- touchkit/py.typed +0 -0
- touchkit/settings.py +85 -0
- touchkit/settings.pyi +17 -0
- touchkit/shell.py +268 -0
- touchkit/shell.pyi +42 -0
- touchkit/ui.py +167 -0
- touchkit/ui.pyi +53 -0
sayso/object_specs.pyi
ADDED
sayso/objects.py
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
from .object_specs import SPOTIFY_OBJECT_SPECS
|
|
6
|
+
from .transport import TransportError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
_MISSING = object()
|
|
10
|
+
_current_client = None
|
|
11
|
+
_CLASS_REGISTRY = {}
|
|
12
|
+
_PAGE_FIELDS = ("href", "limit", "next", "offset", "previous", "total")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class HydrationError(Exception):
|
|
16
|
+
def __init__(self, message, cause=None):
|
|
17
|
+
self.args = (message,)
|
|
18
|
+
self.cause = cause
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def set_client(client):
|
|
22
|
+
global _current_client
|
|
23
|
+
_current_client = client
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_client():
|
|
27
|
+
return _current_client
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _hydration_error(obj, error, page_method=None):
|
|
31
|
+
endpoint = page_method or obj.__class__._fetch_method
|
|
32
|
+
name = obj.__class__.__name__
|
|
33
|
+
object_id = obj._peek("id")
|
|
34
|
+
|
|
35
|
+
message = "Failed to hydrate {}".format(name)
|
|
36
|
+
if object_id is not None:
|
|
37
|
+
message += " (id={!r})".format(object_id)
|
|
38
|
+
if endpoint is not None:
|
|
39
|
+
message += " via {}()".format(endpoint)
|
|
40
|
+
if error.status is not None:
|
|
41
|
+
message += ": HTTP {}".format(error.status)
|
|
42
|
+
|
|
43
|
+
if endpoint == "user":
|
|
44
|
+
message += (
|
|
45
|
+
". GET /users/{id} is unavailable in Spotify Dev Mode;"
|
|
46
|
+
" use client.me() for the current user."
|
|
47
|
+
)
|
|
48
|
+
elif error.status == 403:
|
|
49
|
+
message += (
|
|
50
|
+
" This may be a followed playlist, collaborator restriction,"
|
|
51
|
+
" or a February 2026 Dev Mode removed endpoint."
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return HydrationError(message, error)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class SpotifyObject:
|
|
58
|
+
_fetch_method = None
|
|
59
|
+
|
|
60
|
+
def __init__(self, data=None, **kwargs):
|
|
61
|
+
if data is None:
|
|
62
|
+
data = kwargs
|
|
63
|
+
elif kwargs:
|
|
64
|
+
data.update(kwargs)
|
|
65
|
+
|
|
66
|
+
self._data = data or {}
|
|
67
|
+
self._fetched = False
|
|
68
|
+
|
|
69
|
+
def _peek(self, field):
|
|
70
|
+
value = self._data.get(field, _MISSING)
|
|
71
|
+
if value is _MISSING:
|
|
72
|
+
return None
|
|
73
|
+
return value
|
|
74
|
+
|
|
75
|
+
def _can_hydrate(self):
|
|
76
|
+
return self.__class__._fetch_method is not None
|
|
77
|
+
|
|
78
|
+
def _get(self, field):
|
|
79
|
+
value = self._data.get(field, _MISSING)
|
|
80
|
+
|
|
81
|
+
if value is _MISSING and not self._fetched:
|
|
82
|
+
self._fetch()
|
|
83
|
+
value = self._data.get(field, _MISSING)
|
|
84
|
+
|
|
85
|
+
if value is _MISSING:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
return value
|
|
89
|
+
|
|
90
|
+
def _get_embedded_field(self, field, key):
|
|
91
|
+
data = self._get(field)
|
|
92
|
+
|
|
93
|
+
if (
|
|
94
|
+
not self._fetched
|
|
95
|
+
and self._can_hydrate()
|
|
96
|
+
and (data is None or key not in data)
|
|
97
|
+
):
|
|
98
|
+
self._fetch()
|
|
99
|
+
data = self._peek(field)
|
|
100
|
+
|
|
101
|
+
return data
|
|
102
|
+
|
|
103
|
+
def raw(self):
|
|
104
|
+
return self._data
|
|
105
|
+
|
|
106
|
+
def _fetch(self):
|
|
107
|
+
if self._fetched or not self._can_hydrate():
|
|
108
|
+
return self
|
|
109
|
+
|
|
110
|
+
client = get_client()
|
|
111
|
+
if client is None:
|
|
112
|
+
return self
|
|
113
|
+
|
|
114
|
+
object_id = self._peek("id")
|
|
115
|
+
if object_id is None:
|
|
116
|
+
return self
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
fresh = self._fetch_object(client, object_id)
|
|
120
|
+
except TransportError as error:
|
|
121
|
+
raise _hydration_error(self, error)
|
|
122
|
+
|
|
123
|
+
if fresh is not None:
|
|
124
|
+
self._data.update(fresh.raw())
|
|
125
|
+
self._fetched = True
|
|
126
|
+
|
|
127
|
+
return self
|
|
128
|
+
|
|
129
|
+
def _fetch_object(self, client, object_id):
|
|
130
|
+
return None
|
|
131
|
+
|
|
132
|
+
def _object(self, cls, field):
|
|
133
|
+
data = self._get(field)
|
|
134
|
+
if data is None:
|
|
135
|
+
return None
|
|
136
|
+
return cls(data)
|
|
137
|
+
|
|
138
|
+
def _objects(self, cls, field):
|
|
139
|
+
data = self._get(field)
|
|
140
|
+
if data is None:
|
|
141
|
+
return ()
|
|
142
|
+
return [cls(item) for item in data]
|
|
143
|
+
|
|
144
|
+
def _typed_object(self, field, type_map):
|
|
145
|
+
data = self._get(field)
|
|
146
|
+
if data is None:
|
|
147
|
+
return None
|
|
148
|
+
return _resolve_typed_item(data, type_map)
|
|
149
|
+
|
|
150
|
+
def _typed_objects(self, field, type_map):
|
|
151
|
+
data = self._get(field)
|
|
152
|
+
if data is None:
|
|
153
|
+
return ()
|
|
154
|
+
return [_resolve_typed_item(item, type_map) for item in data]
|
|
155
|
+
|
|
156
|
+
def __repr__(self):
|
|
157
|
+
cls = self.__class__.__name__
|
|
158
|
+
name = self._peek("name")
|
|
159
|
+
object_id = self._peek("id")
|
|
160
|
+
|
|
161
|
+
if name is not None and object_id is not None:
|
|
162
|
+
return "<{} name={!r} id={!r}>".format(cls, name, object_id)
|
|
163
|
+
if object_id is not None:
|
|
164
|
+
return "<{} id={!r}>".format(cls, object_id)
|
|
165
|
+
return "<{}>".format(cls)
|
|
166
|
+
|
|
167
|
+
def __str__(self):
|
|
168
|
+
try:
|
|
169
|
+
import json
|
|
170
|
+
except ImportError:
|
|
171
|
+
return repr(self._data)
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
return json.dumps(self._data, indent=2, sort_keys=True)
|
|
175
|
+
except TypeError:
|
|
176
|
+
return repr(self._data)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class Page(SpotifyObject):
|
|
180
|
+
_item_class = None
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def items(self):
|
|
184
|
+
data = self._peek("items")
|
|
185
|
+
if data is None:
|
|
186
|
+
return ()
|
|
187
|
+
|
|
188
|
+
cls = _resolve_class(self._item_class)
|
|
189
|
+
if cls is None:
|
|
190
|
+
return data
|
|
191
|
+
|
|
192
|
+
return [cls(item) for item in data]
|
|
193
|
+
|
|
194
|
+
def __iter__(self):
|
|
195
|
+
return iter(self.items)
|
|
196
|
+
|
|
197
|
+
def __len__(self):
|
|
198
|
+
return len(self.items)
|
|
199
|
+
|
|
200
|
+
def __getitem__(self, index):
|
|
201
|
+
return self.items[index]
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class LazyPageRef(SpotifyObject):
|
|
205
|
+
def __init__(self, owner, page_method, present_cls_name, ref_data=None):
|
|
206
|
+
super().__init__(ref_data or {})
|
|
207
|
+
self._owner = owner
|
|
208
|
+
self._page_method = page_method
|
|
209
|
+
self._present_cls_name = present_cls_name
|
|
210
|
+
self._page = None
|
|
211
|
+
|
|
212
|
+
def _load_page(self):
|
|
213
|
+
if self._page is not None:
|
|
214
|
+
return self._page
|
|
215
|
+
|
|
216
|
+
client = get_client()
|
|
217
|
+
object_id = self._owner._peek("id")
|
|
218
|
+
if client is None or object_id is None:
|
|
219
|
+
raise HydrationError(
|
|
220
|
+
"Cannot load {} without a client and owner id".format(self._page_method)
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
try:
|
|
224
|
+
page = getattr(client, self._page_method)(object_id)
|
|
225
|
+
except TransportError as error:
|
|
226
|
+
raise _hydration_error(self._owner, error, self._page_method)
|
|
227
|
+
|
|
228
|
+
self._page = page
|
|
229
|
+
return self._page
|
|
230
|
+
|
|
231
|
+
def __iter__(self):
|
|
232
|
+
return iter(self._load_page())
|
|
233
|
+
|
|
234
|
+
def __len__(self):
|
|
235
|
+
return len(self._load_page())
|
|
236
|
+
|
|
237
|
+
def __getitem__(self, index):
|
|
238
|
+
return self._load_page()[index]
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _resolve_class(name):
|
|
242
|
+
if name is None:
|
|
243
|
+
return None
|
|
244
|
+
return _CLASS_REGISTRY[name]
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _resolve_typed_item(item, type_map):
|
|
248
|
+
cls_name = type_map.get(item.get("type"))
|
|
249
|
+
if cls_name is None:
|
|
250
|
+
return SpotifyObject(item)
|
|
251
|
+
return _resolve_class(cls_name)(item)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _field_property(field, empty=None):
|
|
255
|
+
def getter(self):
|
|
256
|
+
value = self._get(field)
|
|
257
|
+
if value is None and empty is not None:
|
|
258
|
+
return empty
|
|
259
|
+
return value
|
|
260
|
+
|
|
261
|
+
return property(getter)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _object_property(cls_name, field):
|
|
265
|
+
def getter(self):
|
|
266
|
+
return self._object(_resolve_class(cls_name), field)
|
|
267
|
+
|
|
268
|
+
return property(getter)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def _objects_property(cls_name, field):
|
|
272
|
+
def getter(self):
|
|
273
|
+
return self._objects(_resolve_class(cls_name), field)
|
|
274
|
+
|
|
275
|
+
return property(getter)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _object_by_key_property(
|
|
279
|
+
field,
|
|
280
|
+
key,
|
|
281
|
+
present_cls_name,
|
|
282
|
+
absent_cls_name,
|
|
283
|
+
page_method=None,
|
|
284
|
+
lazy=False,
|
|
285
|
+
):
|
|
286
|
+
def getter(self):
|
|
287
|
+
if lazy and page_method is not None:
|
|
288
|
+
data = self._peek(field)
|
|
289
|
+
if data is None and not self._fetched and self._can_hydrate():
|
|
290
|
+
self._fetch()
|
|
291
|
+
data = self._peek(field)
|
|
292
|
+
|
|
293
|
+
if data is not None and key in data:
|
|
294
|
+
return _resolve_class(present_cls_name)(data)
|
|
295
|
+
|
|
296
|
+
return LazyPageRef(self, page_method, present_cls_name, data)
|
|
297
|
+
|
|
298
|
+
data = self._get_embedded_field(field, key)
|
|
299
|
+
|
|
300
|
+
if data is not None and key in data:
|
|
301
|
+
return _resolve_class(present_cls_name)(data)
|
|
302
|
+
|
|
303
|
+
if page_method is not None:
|
|
304
|
+
client = get_client()
|
|
305
|
+
object_id = self._peek("id")
|
|
306
|
+
if client is not None and object_id is not None:
|
|
307
|
+
try:
|
|
308
|
+
return getattr(client, page_method)(object_id)
|
|
309
|
+
except TransportError as error:
|
|
310
|
+
raise _hydration_error(self, error, page_method)
|
|
311
|
+
|
|
312
|
+
if data is None:
|
|
313
|
+
return None
|
|
314
|
+
|
|
315
|
+
return _resolve_class(absent_cls_name)(data)
|
|
316
|
+
|
|
317
|
+
return property(getter)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def _typed_object_property(field, type_map):
|
|
321
|
+
def getter(self):
|
|
322
|
+
return self._typed_object(field, type_map)
|
|
323
|
+
|
|
324
|
+
return property(getter)
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def _typed_objects_property(field, type_map):
|
|
328
|
+
def getter(self):
|
|
329
|
+
return self._typed_objects(field, type_map)
|
|
330
|
+
|
|
331
|
+
return property(getter)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def _property_for_spec(prop):
|
|
335
|
+
field = prop["field"]
|
|
336
|
+
kind = prop.get("kind", "field")
|
|
337
|
+
|
|
338
|
+
if kind == "field":
|
|
339
|
+
return _field_property(field)
|
|
340
|
+
if kind == "tuple":
|
|
341
|
+
return _field_property(field, empty=())
|
|
342
|
+
if kind == "object":
|
|
343
|
+
return _object_property(prop["class"], field)
|
|
344
|
+
if kind == "objects":
|
|
345
|
+
return _objects_property(prop["class"], field)
|
|
346
|
+
if kind == "object_by_key":
|
|
347
|
+
return _object_by_key_property(
|
|
348
|
+
field,
|
|
349
|
+
prop["key"],
|
|
350
|
+
prop["present_class"],
|
|
351
|
+
prop["absent_class"],
|
|
352
|
+
prop.get("page_method"),
|
|
353
|
+
prop.get("lazy", False),
|
|
354
|
+
)
|
|
355
|
+
if kind == "typed_object":
|
|
356
|
+
return _typed_object_property(field, prop["type_map"])
|
|
357
|
+
if kind == "typed_objects":
|
|
358
|
+
return _typed_objects_property(field, prop["type_map"])
|
|
359
|
+
|
|
360
|
+
raise ValueError("unknown property kind: {!r}".format(kind))
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def make_spotify_class(spec):
|
|
364
|
+
name = spec["name"]
|
|
365
|
+
attrs = {}
|
|
366
|
+
|
|
367
|
+
base = spec.get("base")
|
|
368
|
+
if base is not None:
|
|
369
|
+
base_class = _resolve_class(base)
|
|
370
|
+
attrs["_item_class"] = spec.get("item_class")
|
|
371
|
+
else:
|
|
372
|
+
base_class = SpotifyObject
|
|
373
|
+
|
|
374
|
+
for prop in spec.get("properties", ()):
|
|
375
|
+
attrs[prop["field"]] = _property_for_spec(prop)
|
|
376
|
+
|
|
377
|
+
fetch_method = spec.get("fetch_method")
|
|
378
|
+
if fetch_method is not None:
|
|
379
|
+
attrs["_fetch_method"] = fetch_method
|
|
380
|
+
|
|
381
|
+
def _fetch_object(self, client, object_id):
|
|
382
|
+
return getattr(client, fetch_method)(object_id)
|
|
383
|
+
|
|
384
|
+
attrs["_fetch_object"] = _fetch_object
|
|
385
|
+
|
|
386
|
+
return type(name, (base_class,), attrs)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def make_spotify_classes(specs):
|
|
390
|
+
classes = {}
|
|
391
|
+
_CLASS_REGISTRY["Page"] = Page
|
|
392
|
+
_CLASS_REGISTRY["LazyPageRef"] = LazyPageRef
|
|
393
|
+
globals()["Page"] = Page
|
|
394
|
+
globals()["LazyPageRef"] = LazyPageRef
|
|
395
|
+
|
|
396
|
+
for spec in specs:
|
|
397
|
+
cls = make_spotify_class(spec)
|
|
398
|
+
classes[spec["name"]] = cls
|
|
399
|
+
_CLASS_REGISTRY[spec["name"]] = cls
|
|
400
|
+
globals()[spec["name"]] = cls
|
|
401
|
+
return classes
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
for _page_field in _PAGE_FIELDS:
|
|
405
|
+
setattr(Page, _page_field, _field_property(_page_field))
|
|
406
|
+
|
|
407
|
+
for _lazy_ref_field in ("href", "total"):
|
|
408
|
+
setattr(LazyPageRef, _lazy_ref_field, _field_property(_lazy_ref_field))
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
make_spotify_classes(SPOTIFY_OBJECT_SPECS)
|