cutienator 0.0.1.dev0__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.
- cutienator/__init__.py +44 -0
- cutienator/_cpp_addr.py +84 -0
- cutienator/_cpp_box.py +23 -0
- cutienator/_cute_load_hook.py +159 -0
- cutienator/_cute_mixin.py +166 -0
- cutienator/_cute_overload.py +285 -0
- cutienator/_cute_space.py +727 -0
- cutienator/_header_descriptor.py +4 -0
- cutienator/_meta_cute.py +444 -0
- cutienator/_q_binding_storage.py +101 -0
- cutienator/_q_event.py +185 -0
- cutienator/_q_meta_object.py +118 -0
- cutienator/_q_object.py +582 -0
- cutienator/_q_thread.py +106 -0
- cutienator/_q_widget.py +80 -0
- cutienator/_ugly.py +296 -0
- cutienator/_wait.py +303 -0
- cutienator/_waiting_overload.py +261 -0
- cutienator/example/__init__.py +21 -0
- cutienator/example/__main__.py +67 -0
- cutienator/example/_calls.py +107 -0
- cutienator/occult/__init__.py +27 -0
- cutienator/occult/__main__.py +50 -0
- cutienator/occult/_base_meta_ugly.py +29 -0
- cutienator/occult/_build.py +561 -0
- cutienator/occult/_cognito_warning.py +35 -0
- cutienator/occult/_declaration.py +572 -0
- cutienator/occult/_header.py +710 -0
- cutienator/occult/_ritual.py +19 -0
- cutienator/occult/_rituals.py +594 -0
- cutienator/occult/_shared_object.py +292 -0
- cutienator/occult/_symbol.py +162 -0
- cutienator/occult/rituals/q_event.cpp +70 -0
- cutienator/occult/rituals/q_meta_object.cpp +173 -0
- cutienator/occult/rituals/q_object.cpp +178 -0
- cutienator/trial/__init__.py +25 -0
- cutienator/trial/__main__.py +59 -0
- cutienator/trial/_judge.py +589 -0
- cutienator/trial/_q_object_trials.py +38 -0
- cutienator/trial/_trial.py +495 -0
- cutienator/trial/_verdict.py +332 -0
- cutienator-0.0.1.dev0.dist-info/METADATA +33 -0
- cutienator-0.0.1.dev0.dist-info/RECORD +46 -0
- cutienator-0.0.1.dev0.dist-info/WHEEL +5 -0
- cutienator-0.0.1.dev0.dist-info/licenses/LICENSE +201 -0
- cutienator-0.0.1.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CuteOverload is what a cute class body gets when it reads the name
|
|
3
|
+
'overload'.
|
|
4
|
+
"""
|
|
5
|
+
# Apache-2.0 license
|
|
6
|
+
# Copyright (c) 2026 Asger Jon Vistisen
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
from worktoy.dispatch import overload, TypeSig
|
|
12
|
+
|
|
13
|
+
from . import WAIT, WaitingOverload
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING: # pragma: no cover, no mutate
|
|
16
|
+
from typing import Any, Callable
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CuteOverload:
|
|
20
|
+
"""
|
|
21
|
+
Does in a cute class body what worktoy's 'overload' does, and also
|
|
22
|
+
takes a signature naming a late class. See 'WAIT' for the whole
|
|
23
|
+
story; this is step 2 and 3 of it.
|
|
24
|
+
|
|
25
|
+
You do not import it and you do not write its name. A cute class file
|
|
26
|
+
imports worktoy's 'overload' as any worktoy class file does, and the
|
|
27
|
+
body writes '@overload(...)'. When the body reads that name,
|
|
28
|
+
'CuteSpace' hands it this class instead:
|
|
29
|
+
|
|
30
|
+
from worktoy.dispatch import overload
|
|
31
|
+
|
|
32
|
+
class QObject(CuteMixin, metaclass=MetaCute):
|
|
33
|
+
|
|
34
|
+
QThread = WAIT['QThread']
|
|
35
|
+
|
|
36
|
+
@overload(QThread) # this class: 'QThread' is a 'WAIT'
|
|
37
|
+
def moveToThread(self, thread: QThread) -> bool: ...
|
|
38
|
+
|
|
39
|
+
@overload(int) # this class, handing on to worktoy
|
|
40
|
+
def startTimer(self, interval: int) -> int: ...
|
|
41
|
+
|
|
42
|
+
Why it exists
|
|
43
|
+
-------------
|
|
44
|
+
|
|
45
|
+
worktoy's 'overload' checks its signature on the very line it is
|
|
46
|
+
written on, and takes a class or 'THIS' and nothing else. A 'WAIT' is
|
|
47
|
+
refused there, before any namespace or metaclass is asked. So the
|
|
48
|
+
body must get another 'overload' to begin with, and the only one who
|
|
49
|
+
can give it another is the namespace the body runs in.
|
|
50
|
+
|
|
51
|
+
What one use of it does
|
|
52
|
+
-----------------------
|
|
53
|
+
|
|
54
|
+
- '@overload(int)', with classes and 'THIS' only: the very same as
|
|
55
|
+
worktoy's 'overload(int)'. It is called right here, checks the
|
|
56
|
+
signature on this line, and its decorator gets the function. The
|
|
57
|
+
body ends up with worktoy's own record, as in any worktoy class.
|
|
58
|
+
- '@overload(QThread)', with a 'WAIT' among the entries: worktoy's
|
|
59
|
+
'overload' is not called. The entries that are no 'WAIT' are
|
|
60
|
+
checked as worktoy checks them. The function is put in a
|
|
61
|
+
'WaitingOverload' with the entries, and that is what the name is
|
|
62
|
+
bound to. 'CuteSpace' takes it from there.
|
|
63
|
+
- 'overload.fallback', 'overload.finalize' and 'overload.flex' are
|
|
64
|
+
worktoy's own, reached through this class.
|
|
65
|
+
|
|
66
|
+
What to expect
|
|
67
|
+
--------------
|
|
68
|
+
|
|
69
|
+
- A signature with nothing late in it behaves exactly as in a class
|
|
70
|
+
that is not cute. Nothing is added to it and nothing is checked
|
|
71
|
+
twice.
|
|
72
|
+
- A waiting signature needs a function of its own. Putting it on a
|
|
73
|
+
function together with other 'overload' decorators is refused with
|
|
74
|
+
'TypeError' on the line of the decorator that meets the other one,
|
|
75
|
+
whichever of the two is written on top.
|
|
76
|
+
- 'overload.flex' with a 'WAIT' is refused with 'TypeError'.
|
|
77
|
+
- '@classmethod' and '@staticmethod' may be written above the
|
|
78
|
+
decorator or below it, as with worktoy's 'overload'.
|
|
79
|
+
- It is never made into an object: calling it gives a decorator, as
|
|
80
|
+
calling worktoy's 'overload' does.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
84
|
+
# STATIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
85
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
def _refuseShared(decorated: Any, decoratorName: str) -> None:
|
|
89
|
+
"""
|
|
90
|
+
Refuses a decorator that would share one function with a waiting
|
|
91
|
+
signature.
|
|
92
|
+
|
|
93
|
+
Parameters
|
|
94
|
+
----------
|
|
95
|
+
|
|
96
|
+
decorated : Any
|
|
97
|
+
What the decorator received, with any 'classmethod' or
|
|
98
|
+
'staticmethod' already taken off.
|
|
99
|
+
|
|
100
|
+
decoratorName : str
|
|
101
|
+
The decorator as the body wrote it, as 'overload.fallback', for
|
|
102
|
+
the message.
|
|
103
|
+
|
|
104
|
+
Raises
|
|
105
|
+
------
|
|
106
|
+
|
|
107
|
+
TypeError
|
|
108
|
+
'decorated' is a 'WaitingOverload'.
|
|
109
|
+
"""
|
|
110
|
+
if not isinstance(decorated, WaitingOverload):
|
|
111
|
+
return
|
|
112
|
+
infoSpec = """'%s' is written above a signature that names a class
|
|
113
|
+
still waited for. Such a signature needs a function of its own:
|
|
114
|
+
write the function a second time for the decorator above it."""
|
|
115
|
+
raise TypeError(' '.join((infoSpec % decoratorName).split()))
|
|
116
|
+
|
|
117
|
+
@staticmethod
|
|
118
|
+
def fallback(function: Any) -> Any:
|
|
119
|
+
"""
|
|
120
|
+
worktoy's 'overload.fallback', reached through the name 'overload'
|
|
121
|
+
of a cute class body. See there for what it does.
|
|
122
|
+
|
|
123
|
+
Raises
|
|
124
|
+
------
|
|
125
|
+
|
|
126
|
+
TypeError
|
|
127
|
+
It is written above a waiting signature on one function.
|
|
128
|
+
"""
|
|
129
|
+
_, decorated = overload.peelMethodKinds(function)
|
|
130
|
+
CuteOverload._refuseShared(decorated, 'overload.fallback')
|
|
131
|
+
return overload.fallback(function)
|
|
132
|
+
|
|
133
|
+
@staticmethod
|
|
134
|
+
def finalize(function: Any) -> Any:
|
|
135
|
+
"""
|
|
136
|
+
worktoy's 'overload.finalize', reached through the name 'overload'
|
|
137
|
+
of a cute class body. See there for what it does.
|
|
138
|
+
|
|
139
|
+
Raises
|
|
140
|
+
------
|
|
141
|
+
|
|
142
|
+
TypeError
|
|
143
|
+
It is written above a waiting signature on one function.
|
|
144
|
+
"""
|
|
145
|
+
_, decorated = overload.peelMethodKinds(function)
|
|
146
|
+
CuteOverload._refuseShared(decorated, 'overload.finalize')
|
|
147
|
+
return overload.finalize(function)
|
|
148
|
+
|
|
149
|
+
@staticmethod
|
|
150
|
+
def flex(*signatureEntries: Any) -> Callable:
|
|
151
|
+
"""
|
|
152
|
+
worktoy's 'overload.flex', reached through the name 'overload' of a
|
|
153
|
+
cute class body. See there for what it does.
|
|
154
|
+
|
|
155
|
+
Raises
|
|
156
|
+
------
|
|
157
|
+
|
|
158
|
+
TypeError
|
|
159
|
+
A 'WAIT' is among the entries, or it is written above a waiting
|
|
160
|
+
signature on one function.
|
|
161
|
+
"""
|
|
162
|
+
for entry in signatureEntries:
|
|
163
|
+
if isinstance(entry, WAIT):
|
|
164
|
+
infoSpec = """'overload.flex' cannot take %s: a class still
|
|
165
|
+
waited for can only stand in a plain '@overload(...)'."""
|
|
166
|
+
raise TypeError(' '.join((infoSpec % entry).split()))
|
|
167
|
+
flexDecorator = overload.flex(*signatureEntries)
|
|
168
|
+
|
|
169
|
+
def decorator(function: Any) -> Any:
|
|
170
|
+
_, decorated = overload.peelMethodKinds(function)
|
|
171
|
+
CuteOverload._refuseShared(decorated, 'overload.flex')
|
|
172
|
+
return flexDecorator(function)
|
|
173
|
+
|
|
174
|
+
return decorator
|
|
175
|
+
|
|
176
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
177
|
+
# NAMESPACE # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
178
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
179
|
+
|
|
180
|
+
# Class Variables
|
|
181
|
+
|
|
182
|
+
# Fallback Variables
|
|
183
|
+
|
|
184
|
+
# Private Variables
|
|
185
|
+
|
|
186
|
+
# Public Variables
|
|
187
|
+
|
|
188
|
+
# Virtual Variables
|
|
189
|
+
|
|
190
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
191
|
+
# GETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
192
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
193
|
+
|
|
194
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
195
|
+
# SETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
196
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
197
|
+
|
|
198
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
199
|
+
# NOTIFIERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
200
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
201
|
+
|
|
202
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
203
|
+
# Python API # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
204
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
205
|
+
|
|
206
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
207
|
+
# CONSTRUCTORS # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
208
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
209
|
+
|
|
210
|
+
def __new__(cls, *signatureEntries: Any) -> Callable:
|
|
211
|
+
"""
|
|
212
|
+
Takes what stands between the brackets of '@overload(...)' in a
|
|
213
|
+
cute class body, and gives the decorator for the function below.
|
|
214
|
+
|
|
215
|
+
Parameters
|
|
216
|
+
----------
|
|
217
|
+
|
|
218
|
+
*signatureEntries : Any
|
|
219
|
+
The classes of the arguments after 'self', as for worktoy's
|
|
220
|
+
'overload'. An entry may also be a 'WAIT' bound higher up in the
|
|
221
|
+
same body.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
|
|
226
|
+
Callable
|
|
227
|
+
A decorator. Without a 'WAIT' among the entries it gives what
|
|
228
|
+
worktoy's own decorator gives. With one, it gives a
|
|
229
|
+
'WaitingOverload' holding the entries, the function, and any
|
|
230
|
+
'classmethod' or 'staticmethod' found around the function.
|
|
231
|
+
|
|
232
|
+
Raises
|
|
233
|
+
------
|
|
234
|
+
|
|
235
|
+
TypeException, TypeError, UncheckableType
|
|
236
|
+
An entry is no class, as worktoy's 'overload' refuses it. Raised
|
|
237
|
+
on this line.
|
|
238
|
+
"""
|
|
239
|
+
waits = [e for e in signatureEntries if isinstance(e, WAIT)]
|
|
240
|
+
if waits:
|
|
241
|
+
rest = [e for e in signatureEntries if not isinstance(e, WAIT)]
|
|
242
|
+
TypeSig.validateTypes(*rest, variadic=False)
|
|
243
|
+
plainDecorator = None
|
|
244
|
+
else:
|
|
245
|
+
plainDecorator = overload(*signatureEntries)
|
|
246
|
+
|
|
247
|
+
def decorator(function: Any) -> Any:
|
|
248
|
+
"""Decorates the function below one '@overload(...)' line."""
|
|
249
|
+
methodKinds, decorated = overload.peelMethodKinds(function)
|
|
250
|
+
cls._refuseShared(decorated, 'overload')
|
|
251
|
+
if plainDecorator is not None:
|
|
252
|
+
return plainDecorator(function)
|
|
253
|
+
if isinstance(decorated, overload):
|
|
254
|
+
infoSpec = """The signature naming %s is written above another
|
|
255
|
+
'overload' decorator. A signature naming a class still waited
|
|
256
|
+
for needs a function of its own: write the function once more
|
|
257
|
+
for it."""
|
|
258
|
+
raise TypeError(' '.join((infoSpec % waits[0]).split()))
|
|
259
|
+
waitingOverload = WaitingOverload()
|
|
260
|
+
waitingOverload.setSignatureEntries(*signatureEntries)
|
|
261
|
+
waitingOverload.setFunction(decorated)
|
|
262
|
+
waitingOverload.setMethodKinds(*methodKinds)
|
|
263
|
+
return waitingOverload
|
|
264
|
+
|
|
265
|
+
return decorator
|
|
266
|
+
|
|
267
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
268
|
+
# DOMAIN SPECIFIC # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
269
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
270
|
+
|
|
271
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
272
|
+
# OPTIONAL METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
273
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
274
|
+
|
|
275
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
276
|
+
# REQUIRED METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
277
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
278
|
+
|
|
279
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
280
|
+
# PARENT METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
281
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
282
|
+
|
|
283
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
284
|
+
# PUBLIC METHODS # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
285
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|