omlish 0.0.0.dev404__py3-none-any.whl → 0.0.0.dev406__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.
- omlish/.manifests.json +78 -78
- omlish/__about__.py +3 -3
- omlish/bootstrap/__main__.py +3 -3
- omlish/codecs/base.py +4 -4
- omlish/codecs/registry.py +1 -4
- omlish/collections/identity.py +3 -0
- omlish/diag/procfs.py +3 -3
- omlish/formats/codecs.py +4 -4
- omlish/io/compress/codecs.py +4 -4
- omlish/lite/contextmanagers.py +10 -7
- omlish/manifests/base.py +4 -4
- omlish/manifests/globals.py +46 -11
- omlish/manifests/loading.py +356 -183
- omlish/manifests/static.py +2 -2
- omlish/manifests/types.py +2 -2
- omlish/os/pidfiles/__main__.py +3 -3
- omlish/secrets/pwgen.py +3 -3
- omlish/specs/jmespath/__main__.py +3 -3
- {omlish-0.0.0.dev404.dist-info → omlish-0.0.0.dev406.dist-info}/METADATA +3 -3
- {omlish-0.0.0.dev404.dist-info → omlish-0.0.0.dev406.dist-info}/RECORD +24 -24
- {omlish-0.0.0.dev404.dist-info → omlish-0.0.0.dev406.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev404.dist-info → omlish-0.0.0.dev406.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev404.dist-info → omlish-0.0.0.dev406.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev404.dist-info → omlish-0.0.0.dev406.dist-info}/top_level.txt +0 -0
omlish/.manifests.json
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
"file": "omlish/bootstrap/__main__.py",
|
6
6
|
"line": 1,
|
7
7
|
"value": {
|
8
|
-
"
|
9
|
-
"
|
10
|
-
"
|
8
|
+
"!omdev.cli.types.CliModule": {
|
9
|
+
"name": "bootstrap",
|
10
|
+
"module": "omlish.bootstrap.__main__"
|
11
11
|
}
|
12
12
|
}
|
13
13
|
},
|
@@ -17,9 +17,9 @@
|
|
17
17
|
"file": "omlish/diag/procfs.py",
|
18
18
|
"line": 361,
|
19
19
|
"value": {
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
20
|
+
"!omdev.cli.types.CliModule": {
|
21
|
+
"name": "procfs",
|
22
|
+
"module": "omlish.diag.procfs"
|
23
23
|
}
|
24
24
|
}
|
25
25
|
},
|
@@ -29,9 +29,9 @@
|
|
29
29
|
"file": "omlish/formats/cbor.py",
|
30
30
|
"line": 30,
|
31
31
|
"value": {
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
32
|
+
"!.codecs.base.LazyLoadedCodec": {
|
33
|
+
"module": "omlish.formats.cbor",
|
34
|
+
"attr": "CBOR_CODEC",
|
35
35
|
"name": "cbor",
|
36
36
|
"aliases": null
|
37
37
|
}
|
@@ -43,9 +43,9 @@
|
|
43
43
|
"file": "omlish/formats/cloudpickle.py",
|
44
44
|
"line": 30,
|
45
45
|
"value": {
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
46
|
+
"!.codecs.base.LazyLoadedCodec": {
|
47
|
+
"module": "omlish.formats.cloudpickle",
|
48
|
+
"attr": "CLOUDPICKLE_CODEC",
|
49
49
|
"name": "cloudpickle",
|
50
50
|
"aliases": null
|
51
51
|
}
|
@@ -57,9 +57,9 @@
|
|
57
57
|
"file": "omlish/formats/edn/codec.py",
|
58
58
|
"line": 25,
|
59
59
|
"value": {
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
60
|
+
"!.codecs.base.LazyLoadedCodec": {
|
61
|
+
"module": "omlish.formats.edn.codec",
|
62
|
+
"attr": "EDN_CODEC",
|
63
63
|
"name": "edn",
|
64
64
|
"aliases": null
|
65
65
|
}
|
@@ -71,9 +71,9 @@
|
|
71
71
|
"file": "omlish/formats/ini/codec.py",
|
72
72
|
"line": 25,
|
73
73
|
"value": {
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
74
|
+
"!.codecs.base.LazyLoadedCodec": {
|
75
|
+
"module": "omlish.formats.ini.codec",
|
76
|
+
"attr": "INI_CODEC",
|
77
77
|
"name": "ini",
|
78
78
|
"aliases": null
|
79
79
|
}
|
@@ -85,9 +85,9 @@
|
|
85
85
|
"file": "omlish/formats/json/codecs.py",
|
86
86
|
"line": 14,
|
87
87
|
"value": {
|
88
|
-
"
|
89
|
-
"
|
90
|
-
"
|
88
|
+
"!.codecs.base.LazyLoadedCodec": {
|
89
|
+
"module": "omlish.formats.json.codecs",
|
90
|
+
"attr": "JSON_CODEC",
|
91
91
|
"name": "json",
|
92
92
|
"aliases": null
|
93
93
|
}
|
@@ -99,9 +99,9 @@
|
|
99
99
|
"file": "omlish/formats/json/codecs.py",
|
100
100
|
"line": 21,
|
101
101
|
"value": {
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
102
|
+
"!.codecs.base.LazyLoadedCodec": {
|
103
|
+
"module": "omlish.formats.json.codecs",
|
104
|
+
"attr": "JSON_COMPACT_CODEC",
|
105
105
|
"name": "json-compact",
|
106
106
|
"aliases": null
|
107
107
|
}
|
@@ -113,9 +113,9 @@
|
|
113
113
|
"file": "omlish/formats/json/codecs.py",
|
114
114
|
"line": 28,
|
115
115
|
"value": {
|
116
|
-
"
|
117
|
-
"
|
118
|
-
"
|
116
|
+
"!.codecs.base.LazyLoadedCodec": {
|
117
|
+
"module": "omlish.formats.json.codecs",
|
118
|
+
"attr": "JSON_PRETTY_CODEC",
|
119
119
|
"name": "json-pretty",
|
120
120
|
"aliases": null
|
121
121
|
}
|
@@ -127,9 +127,9 @@
|
|
127
127
|
"file": "omlish/formats/json5/codec.py",
|
128
128
|
"line": 73,
|
129
129
|
"value": {
|
130
|
-
"
|
131
|
-
"
|
132
|
-
"
|
130
|
+
"!.codecs.base.LazyLoadedCodec": {
|
131
|
+
"module": "omlish.formats.json5.codec",
|
132
|
+
"attr": "JSON5_CODEC",
|
133
133
|
"name": "json5",
|
134
134
|
"aliases": null
|
135
135
|
}
|
@@ -141,9 +141,9 @@
|
|
141
141
|
"file": "omlish/formats/pickle.py",
|
142
142
|
"line": 30,
|
143
143
|
"value": {
|
144
|
-
"
|
145
|
-
"
|
146
|
-
"
|
144
|
+
"!.codecs.base.LazyLoadedCodec": {
|
145
|
+
"module": "omlish.formats.pickle",
|
146
|
+
"attr": "PICKLE_CODEC",
|
147
147
|
"name": "pickle",
|
148
148
|
"aliases": null
|
149
149
|
}
|
@@ -155,9 +155,9 @@
|
|
155
155
|
"file": "omlish/formats/repr.py",
|
156
156
|
"line": 24,
|
157
157
|
"value": {
|
158
|
-
"
|
159
|
-
"
|
160
|
-
"
|
158
|
+
"!.codecs.base.LazyLoadedCodec": {
|
159
|
+
"module": "omlish.formats.repr",
|
160
|
+
"attr": "REPR_CODEC",
|
161
161
|
"name": "repr",
|
162
162
|
"aliases": null
|
163
163
|
}
|
@@ -169,9 +169,9 @@
|
|
169
169
|
"file": "omlish/formats/toml/codec.py",
|
170
170
|
"line": 16,
|
171
171
|
"value": {
|
172
|
-
"
|
173
|
-
"
|
174
|
-
"
|
172
|
+
"!.codecs.base.LazyLoadedCodec": {
|
173
|
+
"module": "omlish.formats.toml.codec",
|
174
|
+
"attr": "TOML_CODEC",
|
175
175
|
"name": "toml",
|
176
176
|
"aliases": null
|
177
177
|
}
|
@@ -183,9 +183,9 @@
|
|
183
183
|
"file": "omlish/formats/yaml.py",
|
184
184
|
"line": 255,
|
185
185
|
"value": {
|
186
|
-
"
|
187
|
-
"
|
188
|
-
"
|
186
|
+
"!.codecs.base.LazyLoadedCodec": {
|
187
|
+
"module": "omlish.formats.yaml",
|
188
|
+
"attr": "YAML_CODEC",
|
189
189
|
"name": "yaml",
|
190
190
|
"aliases": [
|
191
191
|
"yml"
|
@@ -199,9 +199,9 @@
|
|
199
199
|
"file": "omlish/formats/yaml.py",
|
200
200
|
"line": 262,
|
201
201
|
"value": {
|
202
|
-
"
|
203
|
-
"
|
204
|
-
"
|
202
|
+
"!.codecs.base.LazyLoadedCodec": {
|
203
|
+
"module": "omlish.formats.yaml",
|
204
|
+
"attr": "YAML_UNSAFE_CODEC",
|
205
205
|
"name": "yaml-unsafe",
|
206
206
|
"aliases": null
|
207
207
|
}
|
@@ -213,9 +213,9 @@
|
|
213
213
|
"file": "omlish/io/compress/brotli.py",
|
214
214
|
"line": 46,
|
215
215
|
"value": {
|
216
|
-
"
|
217
|
-
"
|
218
|
-
"
|
216
|
+
"!.codecs.base.LazyLoadedCodec": {
|
217
|
+
"module": "omlish.io.compress.brotli",
|
218
|
+
"attr": "BROTLI_CODEC",
|
219
219
|
"name": "brotli",
|
220
220
|
"aliases": null
|
221
221
|
}
|
@@ -227,9 +227,9 @@
|
|
227
227
|
"file": "omlish/io/compress/bz2.py",
|
228
228
|
"line": 60,
|
229
229
|
"value": {
|
230
|
-
"
|
231
|
-
"
|
232
|
-
"
|
230
|
+
"!.codecs.base.LazyLoadedCodec": {
|
231
|
+
"module": "omlish.io.compress.bz2",
|
232
|
+
"attr": "BZ2_CODEC",
|
233
233
|
"name": "bz2",
|
234
234
|
"aliases": null
|
235
235
|
}
|
@@ -241,9 +241,9 @@
|
|
241
241
|
"file": "omlish/io/compress/gzip.py",
|
242
242
|
"line": 349,
|
243
243
|
"value": {
|
244
|
-
"
|
245
|
-
"
|
246
|
-
"
|
244
|
+
"!.codecs.base.LazyLoadedCodec": {
|
245
|
+
"module": "omlish.io.compress.gzip",
|
246
|
+
"attr": "GZIP_CODEC",
|
247
247
|
"name": "gzip",
|
248
248
|
"aliases": [
|
249
249
|
"gz"
|
@@ -257,9 +257,9 @@
|
|
257
257
|
"file": "omlish/io/compress/lz4.py",
|
258
258
|
"line": 90,
|
259
259
|
"value": {
|
260
|
-
"
|
261
|
-
"
|
262
|
-
"
|
260
|
+
"!.codecs.base.LazyLoadedCodec": {
|
261
|
+
"module": "omlish.io.compress.lz4",
|
262
|
+
"attr": "LZ4_CODEC",
|
263
263
|
"name": "lz4",
|
264
264
|
"aliases": null
|
265
265
|
}
|
@@ -271,9 +271,9 @@
|
|
271
271
|
"file": "omlish/io/compress/lzma.py",
|
272
272
|
"line": 80,
|
273
273
|
"value": {
|
274
|
-
"
|
275
|
-
"
|
276
|
-
"
|
274
|
+
"!.codecs.base.LazyLoadedCodec": {
|
275
|
+
"module": "omlish.io.compress.lzma",
|
276
|
+
"attr": "LZMA_CODEC",
|
277
277
|
"name": "lzma",
|
278
278
|
"aliases": null
|
279
279
|
}
|
@@ -285,9 +285,9 @@
|
|
285
285
|
"file": "omlish/io/compress/snappy.py",
|
286
286
|
"line": 33,
|
287
287
|
"value": {
|
288
|
-
"
|
289
|
-
"
|
290
|
-
"
|
288
|
+
"!.codecs.base.LazyLoadedCodec": {
|
289
|
+
"module": "omlish.io.compress.snappy",
|
290
|
+
"attr": "SNAPPY_CODEC",
|
291
291
|
"name": "snappy",
|
292
292
|
"aliases": null
|
293
293
|
}
|
@@ -299,9 +299,9 @@
|
|
299
299
|
"file": "omlish/io/compress/zlib.py",
|
300
300
|
"line": 73,
|
301
301
|
"value": {
|
302
|
-
"
|
303
|
-
"
|
304
|
-
"
|
302
|
+
"!.codecs.base.LazyLoadedCodec": {
|
303
|
+
"module": "omlish.io.compress.zlib",
|
304
|
+
"attr": "ZLIB_CODEC",
|
305
305
|
"name": "zlib",
|
306
306
|
"aliases": null
|
307
307
|
}
|
@@ -313,9 +313,9 @@
|
|
313
313
|
"file": "omlish/io/compress/zstd.py",
|
314
314
|
"line": 51,
|
315
315
|
"value": {
|
316
|
-
"
|
317
|
-
"
|
318
|
-
"
|
316
|
+
"!.codecs.base.LazyLoadedCodec": {
|
317
|
+
"module": "omlish.io.compress.zstd",
|
318
|
+
"attr": "ZSTD_CODEC",
|
319
319
|
"name": "zstd",
|
320
320
|
"aliases": null
|
321
321
|
}
|
@@ -327,9 +327,9 @@
|
|
327
327
|
"file": "omlish/os/pidfiles/__main__.py",
|
328
328
|
"line": 1,
|
329
329
|
"value": {
|
330
|
-
"
|
331
|
-
"
|
332
|
-
"
|
330
|
+
"!omdev.cli.types.CliModule": {
|
331
|
+
"name": "pidfiles",
|
332
|
+
"module": "omlish.os.pidfiles.__main__"
|
333
333
|
}
|
334
334
|
}
|
335
335
|
},
|
@@ -339,9 +339,9 @@
|
|
339
339
|
"file": "omlish/secrets/pwgen.py",
|
340
340
|
"line": 78,
|
341
341
|
"value": {
|
342
|
-
"
|
343
|
-
"
|
344
|
-
"
|
342
|
+
"!omdev.cli.types.CliModule": {
|
343
|
+
"name": "pwgen",
|
344
|
+
"module": "omlish.secrets.pwgen"
|
345
345
|
}
|
346
346
|
}
|
347
347
|
},
|
@@ -351,12 +351,12 @@
|
|
351
351
|
"file": "omlish/specs/jmespath/__main__.py",
|
352
352
|
"line": 1,
|
353
353
|
"value": {
|
354
|
-
"
|
355
|
-
"
|
354
|
+
"!omdev.cli.types.CliModule": {
|
355
|
+
"name": [
|
356
356
|
"jmespath",
|
357
357
|
"jp"
|
358
358
|
],
|
359
|
-
"
|
359
|
+
"module": "omlish.specs.jmespath.__main__"
|
360
360
|
}
|
361
361
|
}
|
362
362
|
}
|
omlish/__about__.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
__version__ = '0.0.0.
|
2
|
-
__revision__ = '
|
1
|
+
__version__ = '0.0.0.dev406'
|
2
|
+
__revision__ = '0862d2e5f3852ab4290573b9bea974cf1e8103a3'
|
3
3
|
|
4
4
|
|
5
5
|
#
|
@@ -65,7 +65,7 @@ class Project(ProjectBase):
|
|
65
65
|
|
66
66
|
'formats': [
|
67
67
|
'orjson ~= 3.11',
|
68
|
-
'ujson ~= 5.
|
68
|
+
'ujson ~= 5.11',
|
69
69
|
|
70
70
|
'pyyaml ~= 6.0',
|
71
71
|
|
omlish/bootstrap/__main__.py
CHANGED
omlish/codecs/base.py
CHANGED
@@ -95,13 +95,13 @@ class LazyLoadedCodec(ModAttrManifest):
|
|
95
95
|
@classmethod
|
96
96
|
def new(
|
97
97
|
cls,
|
98
|
-
|
99
|
-
|
98
|
+
module: str,
|
99
|
+
attr: str,
|
100
100
|
codec: Codec,
|
101
101
|
) -> 'LazyLoadedCodec':
|
102
102
|
return cls(
|
103
|
-
|
104
|
-
|
103
|
+
module=module,
|
104
|
+
attr=attr,
|
105
105
|
name=codec.name,
|
106
106
|
aliases=codec.aliases,
|
107
107
|
)
|
omlish/codecs/registry.py
CHANGED
@@ -106,10 +106,7 @@ def _install_standard_codecs(registry: CodecRegistry) -> None:
|
|
106
106
|
|
107
107
|
@cached.function
|
108
108
|
def _build_manifest_lazy_loaded_codecs() -> ta.Sequence[LazyLoadedCodec]:
|
109
|
-
|
110
|
-
pkgs = {__package__.split('.')[0], *ldr.discover_packages()} # FIXME
|
111
|
-
mns = ldr.load(*pkgs, only=[LazyLoadedCodec])
|
112
|
-
return [m.value() for m in mns]
|
109
|
+
return manifest_globals.GlobalManifestLoader.load_values_of(LazyLoadedCodec)
|
113
110
|
|
114
111
|
|
115
112
|
def _install_manifest_lazy_loaded_codecs(registry: CodecRegistry) -> None:
|
omlish/collections/identity.py
CHANGED
@@ -102,6 +102,9 @@ class IdentityWeakKeyDictionary(ta.MutableMapping[K, V]):
|
|
102
102
|
|
103
103
|
See also:
|
104
104
|
https://github.com/python-trio/trio/blob/efd785a20721707b52a6e2289a65e25722b30c96/src/trio/_core/_ki.py#L81
|
105
|
+
|
106
|
+
TODO:
|
107
|
+
- audit for freethreaded
|
105
108
|
"""
|
106
109
|
|
107
110
|
def __init__(self, *args: ta.Any, **kwargs: ta.Any) -> None:
|
omlish/diag/procfs.py
CHANGED
@@ -359,9 +359,9 @@ def _main() -> None:
|
|
359
359
|
|
360
360
|
|
361
361
|
# @omlish-manifest
|
362
|
-
_CLI_MODULE = {'
|
363
|
-
'
|
364
|
-
'
|
362
|
+
_CLI_MODULE = {'!omdev.cli.types.CliModule': {
|
363
|
+
'name': 'procfs',
|
364
|
+
'module': __name__,
|
365
365
|
}}
|
366
366
|
|
367
367
|
|
omlish/formats/codecs.py
CHANGED
@@ -85,12 +85,12 @@ def make_str_object_codec(
|
|
85
85
|
|
86
86
|
|
87
87
|
def make_object_lazy_loaded_codec(
|
88
|
-
|
89
|
-
|
88
|
+
module: str,
|
89
|
+
attr: str,
|
90
90
|
codec: ObjectCodec,
|
91
91
|
) -> codecs.LazyLoadedCodec:
|
92
92
|
return codecs.LazyLoadedCodec.new(
|
93
|
-
|
94
|
-
|
93
|
+
module,
|
94
|
+
attr,
|
95
95
|
codec,
|
96
96
|
)
|
omlish/io/compress/codecs.py
CHANGED
@@ -67,12 +67,12 @@ def make_compression_codec(
|
|
67
67
|
|
68
68
|
|
69
69
|
def make_compression_lazy_loaded_codec(
|
70
|
-
|
71
|
-
|
70
|
+
module: str,
|
71
|
+
attr: str,
|
72
72
|
codec: CompressionCodec,
|
73
73
|
) -> codecs.LazyLoadedCodec:
|
74
74
|
return codecs.LazyLoadedCodec.new(
|
75
|
-
|
76
|
-
|
75
|
+
module,
|
76
|
+
attr,
|
77
77
|
codec,
|
78
78
|
)
|
omlish/lite/contextmanagers.py
CHANGED
@@ -4,8 +4,6 @@ import functools
|
|
4
4
|
import sys
|
5
5
|
import typing as ta
|
6
6
|
|
7
|
-
from .check import check
|
8
|
-
|
9
7
|
|
10
8
|
T = ta.TypeVar('T')
|
11
9
|
ExitStackedT = ta.TypeVar('ExitStackedT', bound='ExitStacked')
|
@@ -50,7 +48,8 @@ class ExitStacked:
|
|
50
48
|
"""
|
51
49
|
|
52
50
|
with self._exit_stacked_init_wrapper():
|
53
|
-
|
51
|
+
if self._exit_stack is not None:
|
52
|
+
raise RuntimeError
|
54
53
|
es = self._exit_stack = contextlib.ExitStack()
|
55
54
|
es.__enter__()
|
56
55
|
try:
|
@@ -78,7 +77,8 @@ class ExitStacked:
|
|
78
77
|
pass
|
79
78
|
|
80
79
|
def _enter_context(self, cm: ta.ContextManager[T]) -> T:
|
81
|
-
es
|
80
|
+
if (es := self._exit_stack) is None:
|
81
|
+
raise RuntimeError
|
82
82
|
return es.enter_context(cm)
|
83
83
|
|
84
84
|
|
@@ -107,7 +107,8 @@ class AsyncExitStacked:
|
|
107
107
|
@ta.final
|
108
108
|
async def __aenter__(self: AsyncExitStackedT) -> AsyncExitStackedT:
|
109
109
|
async with self._async_exit_stacked_init_wrapper():
|
110
|
-
|
110
|
+
if self._exit_stack is not None:
|
111
|
+
raise RuntimeError
|
111
112
|
es = self._exit_stack = contextlib.AsyncExitStack()
|
112
113
|
await es.__aenter__()
|
113
114
|
try:
|
@@ -135,11 +136,13 @@ class AsyncExitStacked:
|
|
135
136
|
pass
|
136
137
|
|
137
138
|
def _enter_context(self, cm: ta.ContextManager[T]) -> T:
|
138
|
-
es
|
139
|
+
if (es := self._exit_stack) is None:
|
140
|
+
raise RuntimeError
|
139
141
|
return es.enter_context(cm)
|
140
142
|
|
141
143
|
async def _enter_async_context(self, cm: ta.AsyncContextManager[T]) -> T:
|
142
|
-
es
|
144
|
+
if (es := self._exit_stack) is None:
|
145
|
+
raise RuntimeError
|
143
146
|
return await es.enter_async_context(cm)
|
144
147
|
|
145
148
|
|
omlish/manifests/base.py
CHANGED
@@ -12,14 +12,14 @@ NameAliasesManifestT = ta.TypeVar('NameAliasesManifestT', bound='NameAliasesMani
|
|
12
12
|
|
13
13
|
@dc.dataclass(frozen=True)
|
14
14
|
class ModAttrManifest:
|
15
|
-
|
16
|
-
|
15
|
+
module: str
|
16
|
+
attr: str
|
17
17
|
|
18
18
|
def load(self) -> ta.Any:
|
19
19
|
import importlib # noqa
|
20
20
|
|
21
|
-
mod = importlib.import_module(self.
|
22
|
-
return getattr(mod, self.
|
21
|
+
mod = importlib.import_module(self.module)
|
22
|
+
return getattr(mod, self.attr)
|
23
23
|
|
24
24
|
|
25
25
|
##
|
omlish/manifests/globals.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
# ruff: noqa: UP045
|
1
|
+
# ruff: noqa: UP006 UP045
|
2
2
|
# @omlish-lite
|
3
|
+
import os
|
3
4
|
import threading
|
4
5
|
import typing as ta
|
5
6
|
|
@@ -7,6 +8,9 @@ from ..lite.marshal import unmarshal_obj
|
|
7
8
|
from .loading import ManifestLoader
|
8
9
|
|
9
10
|
|
11
|
+
T = ta.TypeVar('T')
|
12
|
+
|
13
|
+
|
10
14
|
##
|
11
15
|
|
12
16
|
|
@@ -28,17 +32,20 @@ class GlobalManifestLoader:
|
|
28
32
|
if (inst := cls._instance) is None:
|
29
33
|
with cls._lock:
|
30
34
|
if (inst := cls._instance) is None:
|
31
|
-
inst = cls._instance = ManifestLoader(
|
35
|
+
inst = cls._instance = ManifestLoader(cls.default_config())
|
32
36
|
|
33
37
|
return inst
|
34
38
|
|
35
39
|
@classmethod
|
36
|
-
def initialize(cls,
|
40
|
+
def initialize(cls, config: ta.Optional[ManifestLoader.Config] = None) -> ManifestLoader:
|
37
41
|
with cls._lock:
|
38
42
|
if cls._instance is not None:
|
39
|
-
raise
|
43
|
+
raise RuntimeError(f'{cls.__name__} already initialized')
|
44
|
+
|
45
|
+
if config is None:
|
46
|
+
config = cls.default_config()
|
40
47
|
|
41
|
-
inst = cls._instance = ManifestLoader(
|
48
|
+
inst = cls._instance = ManifestLoader(config)
|
42
49
|
|
43
50
|
return inst
|
44
51
|
|
@@ -49,8 +56,11 @@ class GlobalManifestLoader:
|
|
49
56
|
return unmarshal_obj(kwargs, obj_cls)
|
50
57
|
|
51
58
|
@classmethod
|
52
|
-
def
|
53
|
-
return
|
59
|
+
def default_config(cls) -> ManifestLoader.Config:
|
60
|
+
return ManifestLoader.Config(
|
61
|
+
discover_packages=True,
|
62
|
+
discover_packages_fallback_scan_root_dirs=[os.getcwd()],
|
63
|
+
|
54
64
|
value_instantiator=cls.default_value_instantiator,
|
55
65
|
)
|
56
66
|
|
@@ -59,10 +69,35 @@ class GlobalManifestLoader:
|
|
59
69
|
@classmethod
|
60
70
|
def load(
|
61
71
|
cls,
|
62
|
-
|
63
|
-
|
72
|
+
*,
|
73
|
+
packages: ta.Optional[ta.Collection[str]] = None,
|
74
|
+
classes: ta.Optional[ta.Collection[type]] = None,
|
64
75
|
) -> ta.Sequence[ManifestLoader.LoadedManifest]:
|
65
76
|
return cls.instance().load(
|
66
|
-
|
67
|
-
|
77
|
+
packages=packages,
|
78
|
+
classes=classes,
|
79
|
+
)
|
80
|
+
|
81
|
+
@classmethod
|
82
|
+
def load_values(
|
83
|
+
cls,
|
84
|
+
*,
|
85
|
+
packages: ta.Optional[ta.Collection[str]] = None,
|
86
|
+
classes: ta.Optional[ta.Collection[type]] = None,
|
87
|
+
) -> ta.Sequence[ta.Any]:
|
88
|
+
return cls.instance().load_values(
|
89
|
+
packages=packages,
|
90
|
+
classes=classes,
|
91
|
+
)
|
92
|
+
|
93
|
+
@classmethod
|
94
|
+
def load_values_of(
|
95
|
+
cls,
|
96
|
+
clz: ta.Type[T],
|
97
|
+
*,
|
98
|
+
packages: ta.Optional[ta.Collection[str]] = None,
|
99
|
+
) -> ta.Sequence[T]:
|
100
|
+
return cls.instance().load_values_of(
|
101
|
+
clz,
|
102
|
+
packages=packages,
|
68
103
|
)
|