omlish 0.0.0.dev443__py3-none-any.whl → 0.0.0.dev445__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.
Potentially problematic release.
This version of omlish might be problematic. Click here for more details.
- omlish/__about__.py +5 -2
- omlish/formats/json/stream/lexing.py +47 -33
- omlish/inject/binder.py +3 -1
- omlish/inject/impl/elements.py +3 -1
- omlish/inject/impl/scopes.py +3 -1
- omlish/inject/injector.py +3 -1
- omlish/inject/inspect.py +3 -1
- omlish/inject/managed.py +5 -1
- omlish/inject/maysync.py +3 -1
- omlish/inject/scopes.py +6 -2
- omlish/inject/sync.py +3 -1
- omlish/lang/__init__.py +2 -6
- omlish/lang/imports/_capture.cc +101 -0
- omlish/lang/imports/capture.py +288 -73
- omlish/lang/imports/proxy.py +206 -12
- omlish/lite/asyncs.py +1 -1
- omlish/sync.py +27 -0
- {omlish-0.0.0.dev443.dist-info → omlish-0.0.0.dev445.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev443.dist-info → omlish-0.0.0.dev445.dist-info}/RECORD +23 -23
- omlish/lang/imports/proxyinit.py +0 -176
- {omlish-0.0.0.dev443.dist-info → omlish-0.0.0.dev445.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev443.dist-info → omlish-0.0.0.dev445.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev443.dist-info → omlish-0.0.0.dev445.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev443.dist-info → omlish-0.0.0.dev445.dist-info}/top_level.txt +0 -0
omlish/lang/imports/proxy.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TODO:
|
|
3
|
+
- if already imported just return?
|
|
4
|
+
"""
|
|
1
5
|
import contextlib
|
|
6
|
+
import functools
|
|
2
7
|
import importlib.util
|
|
3
8
|
import types
|
|
4
9
|
import typing as ta
|
|
5
10
|
|
|
11
|
+
from ..lazyglobals import LazyGlobals
|
|
6
12
|
from .capture import ImportCapture
|
|
13
|
+
from .capture import _new_import_capture_hook
|
|
7
14
|
|
|
8
15
|
|
|
9
16
|
##
|
|
@@ -33,10 +40,9 @@ def proxy_import(
|
|
|
33
40
|
return lmod
|
|
34
41
|
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
#
|
|
37
44
|
|
|
38
45
|
|
|
39
|
-
@contextlib.contextmanager
|
|
40
46
|
def auto_proxy_import(
|
|
41
47
|
mod_globals: ta.MutableMapping[str, ta.Any],
|
|
42
48
|
*,
|
|
@@ -44,19 +50,207 @@ def auto_proxy_import(
|
|
|
44
50
|
|
|
45
51
|
unreferenced_callback: ta.Callable[[ta.Mapping[str, ta.Sequence[str | None]]], None] | None = None,
|
|
46
52
|
raise_unreferenced: bool = False,
|
|
47
|
-
|
|
53
|
+
|
|
54
|
+
_stack_offset: int = 0,
|
|
55
|
+
) -> ta.ContextManager[ImportCapture]:
|
|
48
56
|
inst = ImportCapture(
|
|
49
57
|
mod_globals,
|
|
58
|
+
_hook=_new_import_capture_hook(
|
|
59
|
+
mod_globals,
|
|
60
|
+
stack_offset=_stack_offset + 1,
|
|
61
|
+
),
|
|
50
62
|
disable=disable,
|
|
51
63
|
)
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
@contextlib.contextmanager
|
|
66
|
+
def inner() -> ta.Iterator[ImportCapture]:
|
|
67
|
+
with inst.capture(
|
|
68
|
+
unreferenced_callback=unreferenced_callback,
|
|
69
|
+
raise_unreferenced=raise_unreferenced,
|
|
70
|
+
):
|
|
71
|
+
yield inst
|
|
72
|
+
|
|
73
|
+
pkg = mod_globals.get('__package__')
|
|
74
|
+
for pi in inst.captured.imports:
|
|
75
|
+
for sa, ma in pi.attrs:
|
|
76
|
+
mod_globals[ma] = proxy_import(pi.spec + (('.' + sa) if sa is not None else ''), pkg)
|
|
77
|
+
|
|
78
|
+
return inner()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class _ProxyInit:
|
|
85
|
+
class NamePackage(ta.NamedTuple):
|
|
86
|
+
name: str
|
|
87
|
+
package: str
|
|
88
|
+
|
|
89
|
+
class _Import(ta.NamedTuple):
|
|
90
|
+
spec: str
|
|
91
|
+
attr: str | None
|
|
92
|
+
|
|
93
|
+
def __init__(
|
|
94
|
+
self,
|
|
95
|
+
lazy_globals: LazyGlobals,
|
|
96
|
+
name_package: NamePackage,
|
|
97
|
+
) -> None:
|
|
98
|
+
super().__init__()
|
|
99
|
+
|
|
100
|
+
self._lazy_globals = lazy_globals
|
|
101
|
+
self._name_package = name_package
|
|
102
|
+
|
|
103
|
+
self._imps_by_attr: dict[str, _ProxyInit._Import] = {}
|
|
104
|
+
self._mods_by_spec: dict[str, ta.Any] = {}
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def name_package(self) -> NamePackage:
|
|
108
|
+
return self._name_package
|
|
109
|
+
|
|
110
|
+
def add(
|
|
111
|
+
self,
|
|
112
|
+
package: str,
|
|
113
|
+
attrs: ta.Iterable[tuple[str | None, str]],
|
|
114
|
+
) -> None:
|
|
115
|
+
for imp_attr, as_attr in attrs:
|
|
116
|
+
if imp_attr is None:
|
|
117
|
+
self._imps_by_attr[as_attr] = self._Import(package, None)
|
|
118
|
+
self._lazy_globals.set_fn(as_attr, functools.partial(self.get, as_attr))
|
|
119
|
+
|
|
120
|
+
else:
|
|
121
|
+
self._imps_by_attr[as_attr] = self._Import(package, imp_attr)
|
|
122
|
+
self._lazy_globals.set_fn(as_attr, functools.partial(self.get, as_attr))
|
|
123
|
+
|
|
124
|
+
def _import_module(self, name: str) -> ta.Any:
|
|
125
|
+
return importlib.import_module(name, package=self._name_package.package)
|
|
126
|
+
|
|
127
|
+
def get(self, attr: str) -> ta.Any:
|
|
128
|
+
try:
|
|
129
|
+
imp = self._imps_by_attr[attr]
|
|
130
|
+
except KeyError:
|
|
131
|
+
raise AttributeError(attr) # noqa
|
|
132
|
+
|
|
133
|
+
val: ta.Any
|
|
134
|
+
|
|
135
|
+
if imp.attr is None:
|
|
136
|
+
val = self._import_module(imp.spec)
|
|
137
|
+
|
|
138
|
+
else:
|
|
139
|
+
try:
|
|
140
|
+
mod = self._mods_by_spec[imp.spec]
|
|
141
|
+
except KeyError:
|
|
142
|
+
mod = self._import_module(imp.spec)
|
|
143
|
+
self._mods_by_spec[imp.spec] = mod
|
|
144
|
+
|
|
145
|
+
val = getattr(mod, imp.attr)
|
|
146
|
+
|
|
147
|
+
return val
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def proxy_init(
|
|
151
|
+
init_globals: ta.MutableMapping[str, ta.Any],
|
|
152
|
+
spec: str,
|
|
153
|
+
attrs: ta.Iterable[str | tuple[str | None, str | None] | None] | None = None,
|
|
154
|
+
) -> None:
|
|
155
|
+
if isinstance(attrs, str):
|
|
156
|
+
raise TypeError(attrs)
|
|
157
|
+
|
|
158
|
+
if attrs is None:
|
|
159
|
+
attrs = [None]
|
|
160
|
+
|
|
161
|
+
whole_attr = spec.split('.')[-1]
|
|
162
|
+
al: list[tuple[str | None, str]] = []
|
|
163
|
+
for attr in attrs:
|
|
164
|
+
if attr is None:
|
|
165
|
+
al.append((None, whole_attr))
|
|
166
|
+
|
|
167
|
+
elif isinstance(attr, str):
|
|
168
|
+
al.append((attr, attr))
|
|
169
|
+
|
|
170
|
+
elif isinstance(attr, tuple):
|
|
171
|
+
imp_attr, as_attr = attr
|
|
172
|
+
if as_attr is None:
|
|
173
|
+
if imp_attr is None:
|
|
174
|
+
as_attr = whole_attr
|
|
175
|
+
else:
|
|
176
|
+
as_attr = imp_attr
|
|
177
|
+
al.append((imp_attr, as_attr))
|
|
178
|
+
|
|
179
|
+
else:
|
|
180
|
+
raise TypeError(attr)
|
|
181
|
+
|
|
182
|
+
#
|
|
183
|
+
|
|
184
|
+
init_name_package = _ProxyInit.NamePackage(
|
|
185
|
+
init_globals['__name__'],
|
|
186
|
+
init_globals['__package__'],
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
pi: _ProxyInit
|
|
190
|
+
try:
|
|
191
|
+
pi = init_globals['__proxy_init__']
|
|
192
|
+
|
|
193
|
+
except KeyError:
|
|
194
|
+
pi = _ProxyInit(
|
|
195
|
+
LazyGlobals.install(init_globals),
|
|
196
|
+
init_name_package,
|
|
197
|
+
)
|
|
198
|
+
init_globals['__proxy_init__'] = pi
|
|
199
|
+
|
|
200
|
+
else:
|
|
201
|
+
if pi.name_package != init_name_package:
|
|
202
|
+
raise Exception(f'Wrong init name: {pi.name_package=} != {init_name_package=}')
|
|
203
|
+
|
|
204
|
+
pi.add(spec, al)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
#
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def auto_proxy_init(
|
|
211
|
+
init_globals: ta.MutableMapping[str, ta.Any],
|
|
212
|
+
*,
|
|
213
|
+
disable: bool = False,
|
|
214
|
+
eager: bool = False,
|
|
215
|
+
|
|
216
|
+
unreferenced_callback: ta.Callable[[ta.Mapping[str, ta.Sequence[str | None]]], None] | None = None,
|
|
217
|
+
raise_unreferenced: bool = False,
|
|
218
|
+
|
|
219
|
+
update_exports: bool = False,
|
|
220
|
+
|
|
221
|
+
_stack_offset: int = 0,
|
|
222
|
+
) -> ta.ContextManager[ImportCapture]:
|
|
223
|
+
inst = ImportCapture(
|
|
224
|
+
init_globals,
|
|
225
|
+
_hook=_new_import_capture_hook(
|
|
226
|
+
init_globals,
|
|
227
|
+
stack_offset=_stack_offset + 1,
|
|
228
|
+
),
|
|
229
|
+
disable=disable,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
@contextlib.contextmanager
|
|
233
|
+
def inner() -> ta.Iterator[ImportCapture]:
|
|
234
|
+
with inst.capture(
|
|
235
|
+
unreferenced_callback=unreferenced_callback,
|
|
236
|
+
raise_unreferenced=raise_unreferenced,
|
|
237
|
+
):
|
|
238
|
+
yield inst
|
|
239
|
+
|
|
240
|
+
for pi in inst.captured.imports:
|
|
241
|
+
proxy_init(
|
|
242
|
+
init_globals,
|
|
243
|
+
pi.spec,
|
|
244
|
+
pi.attrs,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
if eager:
|
|
248
|
+
lg = LazyGlobals.install(init_globals)
|
|
249
|
+
|
|
250
|
+
for a in inst.captured.attrs:
|
|
251
|
+
lg.get(a)
|
|
252
|
+
|
|
253
|
+
if update_exports:
|
|
254
|
+
inst.update_exports()
|
|
58
255
|
|
|
59
|
-
|
|
60
|
-
for pi in inst.captured.imports:
|
|
61
|
-
for sa, ma in pi.attrs:
|
|
62
|
-
mod_globals[ma] = proxy_import(pi.spec + (('.' + sa) if sa is not None else ''), pkg)
|
|
256
|
+
return inner()
|
omlish/lite/asyncs.py
CHANGED
omlish/sync.py
CHANGED
|
@@ -136,3 +136,30 @@ class ConditionDeque(ta.Generic[T]):
|
|
|
136
136
|
while not self.deque:
|
|
137
137
|
self.cond.wait(timeout)
|
|
138
138
|
return self.deque.popleft()
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
##
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class CountDownLatch:
|
|
145
|
+
def __init__(self, count: int) -> None:
|
|
146
|
+
super().__init__()
|
|
147
|
+
|
|
148
|
+
self._count = count
|
|
149
|
+
self._cond = threading.Condition()
|
|
150
|
+
|
|
151
|
+
def count_down(self) -> None:
|
|
152
|
+
with self._cond:
|
|
153
|
+
self._count -= 1
|
|
154
|
+
if self._count <= 0:
|
|
155
|
+
self._cond.notify_all()
|
|
156
|
+
|
|
157
|
+
def wait(
|
|
158
|
+
self,
|
|
159
|
+
timeout: float | None = None,
|
|
160
|
+
) -> bool:
|
|
161
|
+
with self._cond:
|
|
162
|
+
return self._cond.wait_for(
|
|
163
|
+
lambda: self._count < 1,
|
|
164
|
+
timeout,
|
|
165
|
+
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
omlish/.omlish-manifests.json,sha256=FLw7xkPiSXuImZgqSP8BwrEib2R1doSzUPLUkc-QUIA,8410
|
|
2
|
-
omlish/__about__.py,sha256=
|
|
2
|
+
omlish/__about__.py,sha256=l_CYKLoqEfq6eAr9gqXrD5Kc9h73YjDaqtcp7Jsos90,3613
|
|
3
3
|
omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
|
|
4
4
|
omlish/c3.py,sha256=ZNIMl1kwg3qdei4DiUrJPQe5M81S1e76N-GuNSwLBAE,8683
|
|
5
5
|
omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
|
|
@@ -9,7 +9,7 @@ omlish/libc.py,sha256=mNY2FWZ2BjSucOx5TEW8IP_B5n84tVZWuVPL3Z3sUH8,15644
|
|
|
9
9
|
omlish/metadata.py,sha256=l_GGk0g_GkxltQYNDr-P9TTtvIggkdFtnfIffYtaieQ,3797
|
|
10
10
|
omlish/runmodule.py,sha256=vQ9VZN_c3sQX9rj036dW9lXuMWTjGOfWnwDcWTSWnn0,705
|
|
11
11
|
omlish/shlex.py,sha256=rlbgHWxjwpkCBRphOPqSIN_KD6qWJMLldNJUILulKT0,253
|
|
12
|
-
omlish/sync.py,sha256=
|
|
12
|
+
omlish/sync.py,sha256=bmhoaapdt1WhbL8_BWP9WhCy-u6VeZKnv2k9fzRZDds,3551
|
|
13
13
|
omlish/algorithm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
omlish/algorithm/all.py,sha256=FudUHwoaRLNNmqYM3jhP2Yd2BpmYhNBRPaVZzARMoSc,194
|
|
15
15
|
omlish/algorithm/distribute.py,sha256=juv6JaCynQG6RaxX0fnNNEVJcvZ8hUS2Mv3ND2t9Y3w,1544
|
|
@@ -267,7 +267,7 @@ omlish/formats/json/backends/ujson.py,sha256=U3iOlAURfiCdXbiNlXfIjDdtJDbDaLZsSuZ
|
|
|
267
267
|
omlish/formats/json/stream/__init__.py,sha256=LoYSkdUX3lkQ4g9JB_F6YOeexlOEporKW8bW8tv3YXg,859
|
|
268
268
|
omlish/formats/json/stream/building.py,sha256=QAQaTyXuw9vkfhvzWIh_DSlypD1-HgzO855Dgz3_wFM,2517
|
|
269
269
|
omlish/formats/json/stream/errors.py,sha256=c8M8UAYmIZ-vWZLeKD2jMj4EDCJbr9QR8Jq_DyHjujQ,43
|
|
270
|
-
omlish/formats/json/stream/lexing.py,sha256=
|
|
270
|
+
omlish/formats/json/stream/lexing.py,sha256=iSzZj2BqvG_VTM6gVvia_EfXUFSPvRN378oHcAG6YBU,16533
|
|
271
271
|
omlish/formats/json/stream/parsing.py,sha256=bnTaYcCMRh0i_mByQgq4qtVf53zJnmjPvUDwJ7-zL64,7154
|
|
272
272
|
omlish/formats/json/stream/rendering.py,sha256=E5SXMGcbBtgtUYYznTPZFHD4tmV_X7K3MK50V11ESRk,3611
|
|
273
273
|
omlish/formats/json/stream/utils.py,sha256=vX69i90DVCjAAAohpiLgsT3ZinFS_cYUfneTvx-3dxU,4959
|
|
@@ -337,31 +337,31 @@ omlish/http/coro/server/server.py,sha256=pB-QV70koRtFwmKmyjnriZDJtErhE6dNqTVvF7s
|
|
|
337
337
|
omlish/http/coro/server/simple.py,sha256=j1RZ3niKrgGM2qFnjdYWn_eniZzay5j49Ca4L3u8vO4,3296
|
|
338
338
|
omlish/http/coro/server/sockets.py,sha256=kFZYbcTGYftvm7zpOhkZGtyX2qYdem-Gk018GVBOzeg,2285
|
|
339
339
|
omlish/inject/__init__.py,sha256=8ik0yhn0LCdDr2UMACBeatENs76yprB8pDXUNllXRWg,2954
|
|
340
|
-
omlish/inject/binder.py,sha256=
|
|
340
|
+
omlish/inject/binder.py,sha256=7-Lhf39FuwtpAA57ljJ_h8fIUNCpcd10E6CJiR4Cdxc,5303
|
|
341
341
|
omlish/inject/bindings.py,sha256=PlvOnUREjvc6F8nOJdzl1k9SAf80icRB4qWFqDop87M,536
|
|
342
342
|
omlish/inject/eagers.py,sha256=JBY7PcjXt-Rg9scQ1ol9xpcoTLXkXC_Ie9uwTWdzUkA,340
|
|
343
343
|
omlish/inject/elements.py,sha256=y4luEO_-eOlVnLcUDiNGSyMXee4pusl46ZGr0JFhbcY,1405
|
|
344
344
|
omlish/inject/errors.py,sha256=_wkN2tF55gQzmMOMKJC_9jYHBZzaBiCDcyqI9Sf2UZs,626
|
|
345
|
-
omlish/inject/injector.py,sha256=
|
|
346
|
-
omlish/inject/inspect.py,sha256=
|
|
345
|
+
omlish/inject/injector.py,sha256=Lw8RLPdJYCHx2zYckttcZnAXBg_UYHe6KAeBilpz-SY,1177
|
|
346
|
+
omlish/inject/inspect.py,sha256=Uq4KMloGWF_YS2mgZbrx-JXhZQnYHHKJSr68i9yoBVc,597
|
|
347
347
|
omlish/inject/keys.py,sha256=7jnI2cw7cvLlzZAfe5SC50O3oPOpOB6iGZGTigyfQvs,682
|
|
348
348
|
omlish/inject/listeners.py,sha256=bav7-uzfpajFAmH_snM0PW2oCfMavmhbE6R4-gjOmJ8,620
|
|
349
349
|
omlish/inject/lite.py,sha256=AFOCj_SznDCPjkiVSKdFXL2hH1q2o4kaDnzkxRWDpsI,2615
|
|
350
|
-
omlish/inject/managed.py,sha256=
|
|
351
|
-
omlish/inject/maysync.py,sha256=
|
|
350
|
+
omlish/inject/managed.py,sha256=jaZiiLqHHhL5aHtryou7M15QgHvZ8rSIHveG7ka9sAw,3087
|
|
351
|
+
omlish/inject/maysync.py,sha256=I_gV1efDgqi-A-wJVHAmeswzIxAI0WW_U416E7LnSBs,491
|
|
352
352
|
omlish/inject/multis.py,sha256=Dn63jE8P5ahSKc1IDBdzzx6ByBCgVOth5t4frG9m4UA,3336
|
|
353
353
|
omlish/inject/origins.py,sha256=-qXa18rIIkNwBdTrvASRDjgPYnoY6n6OPC222jJDrXg,551
|
|
354
354
|
omlish/inject/overrides.py,sha256=ybEcq9cDf6kvqu5mqnwi6Evj0MFjKNeE3r0oUlGw5E4,546
|
|
355
355
|
omlish/inject/privates.py,sha256=CyE-hvQ-F_uyCzcwfdiYVtfm9IF1WZvMDOYilFyZmWk,658
|
|
356
356
|
omlish/inject/providers.py,sha256=Usvi0YgjS5jrAqQFhzeU2artxRSTM4zIoz72lac1PEA,931
|
|
357
|
-
omlish/inject/scopes.py,sha256=
|
|
358
|
-
omlish/inject/sync.py,sha256=
|
|
357
|
+
omlish/inject/scopes.py,sha256=9atVF24QEn073kvoCw_4yLrkdIEzSAqqI0cSXAg4G1A,2722
|
|
358
|
+
omlish/inject/sync.py,sha256=ovVoMY7X9hxe1xverBEec4la3j_041HKjNSlarGsfuA,1051
|
|
359
359
|
omlish/inject/tags.py,sha256=gRDLa-WdZc9DC7KwwmoIPAi8g_qdGpRWuMT7HCd7CL0,433
|
|
360
360
|
omlish/inject/types.py,sha256=Z-ZEdgtCpHBNrbxxKaMVvfeD7hYXdL4rC7A9_VGxZ6g,256
|
|
361
361
|
omlish/inject/utils.py,sha256=Gc2qq45KgkyqDt03WSvOEZBCiuqQ6ESwplx5ZRBcY5M,413
|
|
362
362
|
omlish/inject/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
363
363
|
omlish/inject/impl/bindings.py,sha256=xSvUcoDz8NH-aNHPwBPEZsFg73K2WcF_A63npVbGt_k,420
|
|
364
|
-
omlish/inject/impl/elements.py,sha256=
|
|
364
|
+
omlish/inject/impl/elements.py,sha256=BZweNf8lbG_tO5X_A8-yM2ukIwtHHVMR6nsxai95EOA,5948
|
|
365
365
|
omlish/inject/impl/injector.py,sha256=0e8Il9ObzWMDBJDLQk9RRBkK83mk-nIRlKU_LtmQfLI,8266
|
|
366
366
|
omlish/inject/impl/inspect.py,sha256=HLhz5DfP9dwvbIYnwqsfR9ADjCoWs9q4Gh7J4BpImf4,3135
|
|
367
367
|
omlish/inject/impl/maysync.py,sha256=7GWjrvJStOx85BCvk8IJAmmkoGkChFAAi2h7j2pe6Qs,1207
|
|
@@ -371,7 +371,7 @@ omlish/inject/impl/privates.py,sha256=uxMAl0MOPu-MeLd-q1DySu7J5FcdRVL1B0XgC4dnB6
|
|
|
371
371
|
omlish/inject/impl/providers.py,sha256=qqPUF9qZZ-CGTTc7ZPskjexM2aK8xdY0gLPMshB5VKw,2127
|
|
372
372
|
omlish/inject/impl/providers2.py,sha256=NOIbX_sTAL8uXf-lMoOiFTFZQMe6ywLU7nIghgF_ISw,1326
|
|
373
373
|
omlish/inject/impl/proxy.py,sha256=S1qNn-5pbsAj9hhasQZ9nnFSCX8SuAYCcBOZ6BtKxlk,1641
|
|
374
|
-
omlish/inject/impl/scopes.py,sha256=
|
|
374
|
+
omlish/inject/impl/scopes.py,sha256=sqtjHe6g0pAEOHqIARXGiIE9mKmGmlqh1FDpskV4TIw,5923
|
|
375
375
|
omlish/inject/impl/sync.py,sha256=v0FrcMfEFIT358AmAuERvzJ3o19r6DLZj6_0hjuW5Dk,1090
|
|
376
376
|
omlish/io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
377
377
|
omlish/io/abc.py,sha256=M40QB2udYpCEqmlxCcHv6FlJYJY6ymmJQBlaklYv0U8,1256
|
|
@@ -407,7 +407,7 @@ omlish/iterators/recipes.py,sha256=wOwOZg-zWG9Zc3wcAxJFSe2rtavVBYwZOfG09qYEx_4,4
|
|
|
407
407
|
omlish/iterators/tools.py,sha256=M16LXrJhMdsz5ea2qH0vws30ZvhQuQSCVFSLpRf_gTg,2096
|
|
408
408
|
omlish/iterators/transforms.py,sha256=YHVdD9nBkS1k4kogi4Ba0UOTU_pKkuX9jGw1Tqj3UMw,3598
|
|
409
409
|
omlish/iterators/unique.py,sha256=BSE-eanva8byFCJi09Nt2zzTsVr8LnTqY1PIInGYRs0,1396
|
|
410
|
-
omlish/lang/__init__.py,sha256=
|
|
410
|
+
omlish/lang/__init__.py,sha256=sgUJUCPetFmMQ_qv2OuuYO0hk8AZLeSY7bTQPx3LzM8,10551
|
|
411
411
|
omlish/lang/asyncs.py,sha256=iIHJp7nvgJVj7zS0Ji7NsVSzz54vkzrj0Snc83dxe9g,1965
|
|
412
412
|
omlish/lang/attrstorage.py,sha256=UUnoENCMQF3twBfxBcIKa5mpXsAxWnNYDayhU8xgmpU,5224
|
|
413
413
|
omlish/lang/casing.py,sha256=3_c7cxQOc4z_YezaU2B4NCTAsPh_kDL4wUTK5kZU6kg,4675
|
|
@@ -447,11 +447,11 @@ omlish/lang/classes/restrict.py,sha256=xHLIK20MQ_jJPQ7JVzMNhyN4Xc4eLBgrcxqDnTbeK
|
|
|
447
447
|
omlish/lang/classes/simple.py,sha256=3AJSs-plVg2flq4SC6I39LxP0nBaB241puv3D5YCP5I,2973
|
|
448
448
|
omlish/lang/classes/virtual.py,sha256=J4y-uiv1RaP2rfFeptXqQ1a4MRek0TMlAFFraO_lzhs,3397
|
|
449
449
|
omlish/lang/imports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
450
|
-
omlish/lang/imports/
|
|
450
|
+
omlish/lang/imports/_capture.cc,sha256=jAKW9pOV3ER4Vzd-aywmAeOxbv-b_jNdaxAaVdxfueg,2261
|
|
451
|
+
omlish/lang/imports/capture.py,sha256=38jP4ydXgiryz77wZ-52GuPQi2fXUiBYZSzoTuQSLdw,21706
|
|
451
452
|
omlish/lang/imports/conditional.py,sha256=R-E47QD95mMonPImWlrde3rnJrFKCCkYz71c94W05sc,1006
|
|
452
453
|
omlish/lang/imports/lazy.py,sha256=Eefs9hkj5surMdwgxX_Q3BOqPcox10v0sKT5rKIQknc,808
|
|
453
|
-
omlish/lang/imports/proxy.py,sha256=
|
|
454
|
-
omlish/lang/imports/proxyinit.py,sha256=W7_FxDxe4aAQLUxNF1U6-2JROwK75HgRGEGidDKB-t0,4400
|
|
454
|
+
omlish/lang/imports/proxy.py,sha256=wlXJrl1GiXQ-t5cO_aJLqp1mr_Erl4oMk4uySkkK7bg,6516
|
|
455
455
|
omlish/lang/imports/resolving.py,sha256=DeRarn35Fryg5JhVhy8wbiC9lvr58AnllI9B_reswUE,2085
|
|
456
456
|
omlish/lang/imports/traversal.py,sha256=pbFQIa880NGjSfcLsno2vE_G41_CLwDHb-7gWg2J3BI,2855
|
|
457
457
|
omlish/lifecycles/__init__.py,sha256=zOuvV4pErPwxcKUSgshmME2Duw9GrjwckpNmW3FPKng,810
|
|
@@ -465,7 +465,7 @@ omlish/lifecycles/transitions.py,sha256=3IFdWGtAeoy3XRlIyW7yCKV4e4Iof9ytkqklGMRF
|
|
|
465
465
|
omlish/lite/__init__.py,sha256=cyZEpGob7XjU8DohyNxVe5CQRk4CQ5vrHL42OdhQb8w,148
|
|
466
466
|
omlish/lite/abstract.py,sha256=Z3kLviPNGLkmA8m8BZILzWxez_sP18OyzgMP3-c2-RI,4068
|
|
467
467
|
omlish/lite/args.py,sha256=ILJXAiN3KjIoJwY42aKpYPngUdxHIy9ssVIExFVz3fE,978
|
|
468
|
-
omlish/lite/asyncs.py,sha256=
|
|
468
|
+
omlish/lite/asyncs.py,sha256=ITnHvg1gq4Wl6PmhwK6DTKriNLBfxFfiVLE9QL6LEHk,3254
|
|
469
469
|
omlish/lite/attrops.py,sha256=FD4QFnNqDyLCbVPIP8Zq-6gCZoqHgrH-0z4200huL9U,11243
|
|
470
470
|
omlish/lite/cached.py,sha256=AF0PdB2k4h2dyNc5tzrmnNrb9zKnoMPQU3WA8KrhS_o,3108
|
|
471
471
|
omlish/lite/check.py,sha256=ytCkwZoKfOlJqylL-AGm8C2WfsWJd2q3kFbnZCzX3_M,13844
|
|
@@ -820,9 +820,9 @@ omlish/typedvalues/marshal.py,sha256=AtBz7Jq-BfW8vwM7HSxSpR85JAXmxK2T0xDblmm1HI0
|
|
|
820
820
|
omlish/typedvalues/of_.py,sha256=UXkxSj504WI2UrFlqdZJbu2hyDwBhL7XVrc2qdR02GQ,1309
|
|
821
821
|
omlish/typedvalues/reflect.py,sha256=PAvKW6T4cW7u--iX80w3HWwZUS3SmIZ2_lQjT65uAyk,1026
|
|
822
822
|
omlish/typedvalues/values.py,sha256=ym46I-q2QJ_6l4UlERqv3yj87R-kp8nCKMRph0xQ3UA,1307
|
|
823
|
-
omlish-0.0.0.
|
|
824
|
-
omlish-0.0.0.
|
|
825
|
-
omlish-0.0.0.
|
|
826
|
-
omlish-0.0.0.
|
|
827
|
-
omlish-0.0.0.
|
|
828
|
-
omlish-0.0.0.
|
|
823
|
+
omlish-0.0.0.dev445.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
824
|
+
omlish-0.0.0.dev445.dist-info/METADATA,sha256=agRgaRokAzMENgsipDKwsg8FjW0uO6bc6kgfzwkTZ-8,19003
|
|
825
|
+
omlish-0.0.0.dev445.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
826
|
+
omlish-0.0.0.dev445.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
|
827
|
+
omlish-0.0.0.dev445.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
|
828
|
+
omlish-0.0.0.dev445.dist-info/RECORD,,
|
omlish/lang/imports/proxyinit.py
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import contextlib
|
|
2
|
-
import functools
|
|
3
|
-
import importlib.util
|
|
4
|
-
import typing as ta
|
|
5
|
-
|
|
6
|
-
from ..lazyglobals import LazyGlobals
|
|
7
|
-
from .capture import ImportCapture
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class _ProxyInit:
|
|
14
|
-
class NamePackage(ta.NamedTuple):
|
|
15
|
-
name: str
|
|
16
|
-
package: str
|
|
17
|
-
|
|
18
|
-
class _Import(ta.NamedTuple):
|
|
19
|
-
spec: str
|
|
20
|
-
attr: str | None
|
|
21
|
-
|
|
22
|
-
def __init__(
|
|
23
|
-
self,
|
|
24
|
-
lazy_globals: LazyGlobals,
|
|
25
|
-
name_package: NamePackage,
|
|
26
|
-
) -> None:
|
|
27
|
-
super().__init__()
|
|
28
|
-
|
|
29
|
-
self._lazy_globals = lazy_globals
|
|
30
|
-
self._name_package = name_package
|
|
31
|
-
|
|
32
|
-
self._imps_by_attr: dict[str, _ProxyInit._Import] = {}
|
|
33
|
-
self._mods_by_spec: dict[str, ta.Any] = {}
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def name_package(self) -> NamePackage:
|
|
37
|
-
return self._name_package
|
|
38
|
-
|
|
39
|
-
def add(
|
|
40
|
-
self,
|
|
41
|
-
package: str,
|
|
42
|
-
attrs: ta.Iterable[tuple[str | None, str]],
|
|
43
|
-
) -> None:
|
|
44
|
-
for imp_attr, as_attr in attrs:
|
|
45
|
-
if imp_attr is None:
|
|
46
|
-
self._imps_by_attr[as_attr] = self._Import(package, None)
|
|
47
|
-
self._lazy_globals.set_fn(as_attr, functools.partial(self.get, as_attr))
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
self._imps_by_attr[as_attr] = self._Import(package, imp_attr)
|
|
51
|
-
self._lazy_globals.set_fn(as_attr, functools.partial(self.get, as_attr))
|
|
52
|
-
|
|
53
|
-
def _import_module(self, name: str) -> ta.Any:
|
|
54
|
-
return importlib.import_module(name, package=self._name_package.package)
|
|
55
|
-
|
|
56
|
-
def get(self, attr: str) -> ta.Any:
|
|
57
|
-
try:
|
|
58
|
-
imp = self._imps_by_attr[attr]
|
|
59
|
-
except KeyError:
|
|
60
|
-
raise AttributeError(attr) # noqa
|
|
61
|
-
|
|
62
|
-
val: ta.Any
|
|
63
|
-
|
|
64
|
-
if imp.attr is None:
|
|
65
|
-
val = self._import_module(imp.spec)
|
|
66
|
-
|
|
67
|
-
else:
|
|
68
|
-
try:
|
|
69
|
-
mod = self._mods_by_spec[imp.spec]
|
|
70
|
-
except KeyError:
|
|
71
|
-
mod = self._import_module(imp.spec)
|
|
72
|
-
self._mods_by_spec[imp.spec] = mod
|
|
73
|
-
|
|
74
|
-
val = getattr(mod, imp.attr)
|
|
75
|
-
|
|
76
|
-
return val
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def proxy_init(
|
|
80
|
-
init_globals: ta.MutableMapping[str, ta.Any],
|
|
81
|
-
spec: str,
|
|
82
|
-
attrs: ta.Iterable[str | tuple[str | None, str | None] | None] | None = None,
|
|
83
|
-
) -> None:
|
|
84
|
-
if isinstance(attrs, str):
|
|
85
|
-
raise TypeError(attrs)
|
|
86
|
-
|
|
87
|
-
if attrs is None:
|
|
88
|
-
attrs = [None]
|
|
89
|
-
|
|
90
|
-
whole_attr = spec.split('.')[-1]
|
|
91
|
-
al: list[tuple[str | None, str]] = []
|
|
92
|
-
for attr in attrs:
|
|
93
|
-
if attr is None:
|
|
94
|
-
al.append((None, whole_attr))
|
|
95
|
-
|
|
96
|
-
elif isinstance(attr, str):
|
|
97
|
-
al.append((attr, attr))
|
|
98
|
-
|
|
99
|
-
elif isinstance(attr, tuple):
|
|
100
|
-
imp_attr, as_attr = attr
|
|
101
|
-
if as_attr is None:
|
|
102
|
-
if imp_attr is None:
|
|
103
|
-
as_attr = whole_attr
|
|
104
|
-
else:
|
|
105
|
-
as_attr = imp_attr
|
|
106
|
-
al.append((imp_attr, as_attr))
|
|
107
|
-
|
|
108
|
-
else:
|
|
109
|
-
raise TypeError(attr)
|
|
110
|
-
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
init_name_package = _ProxyInit.NamePackage(
|
|
114
|
-
init_globals['__name__'],
|
|
115
|
-
init_globals['__package__'],
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
pi: _ProxyInit
|
|
119
|
-
try:
|
|
120
|
-
pi = init_globals['__proxy_init__']
|
|
121
|
-
|
|
122
|
-
except KeyError:
|
|
123
|
-
pi = _ProxyInit(
|
|
124
|
-
LazyGlobals.install(init_globals),
|
|
125
|
-
init_name_package,
|
|
126
|
-
)
|
|
127
|
-
init_globals['__proxy_init__'] = pi
|
|
128
|
-
|
|
129
|
-
else:
|
|
130
|
-
if pi.name_package != init_name_package:
|
|
131
|
-
raise Exception(f'Wrong init name: {pi.name_package=} != {init_name_package=}')
|
|
132
|
-
|
|
133
|
-
pi.add(spec, al)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
@contextlib.contextmanager
|
|
140
|
-
def auto_proxy_init(
|
|
141
|
-
init_globals: ta.MutableMapping[str, ta.Any],
|
|
142
|
-
*,
|
|
143
|
-
disable: bool = False,
|
|
144
|
-
eager: bool = False,
|
|
145
|
-
|
|
146
|
-
unreferenced_callback: ta.Callable[[ta.Mapping[str, ta.Sequence[str | None]]], None] | None = None,
|
|
147
|
-
raise_unreferenced: bool = False,
|
|
148
|
-
|
|
149
|
-
update_exports: bool = False,
|
|
150
|
-
) -> ta.Iterator[ImportCapture]:
|
|
151
|
-
inst = ImportCapture(
|
|
152
|
-
init_globals,
|
|
153
|
-
disable=disable,
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
with inst.capture(
|
|
157
|
-
unreferenced_callback=unreferenced_callback,
|
|
158
|
-
raise_unreferenced=raise_unreferenced,
|
|
159
|
-
):
|
|
160
|
-
yield inst
|
|
161
|
-
|
|
162
|
-
for pi in inst.captured.imports:
|
|
163
|
-
proxy_init(
|
|
164
|
-
init_globals,
|
|
165
|
-
pi.spec,
|
|
166
|
-
pi.attrs,
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
if eager:
|
|
170
|
-
lg = LazyGlobals.install(init_globals)
|
|
171
|
-
|
|
172
|
-
for a in inst.captured.attrs:
|
|
173
|
-
lg.get(a)
|
|
174
|
-
|
|
175
|
-
if update_exports:
|
|
176
|
-
inst.update_exports()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|