omlish 0.0.0.dev447__py3-none-any.whl → 0.0.0.dev484__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/.omlish-manifests.json +12 -0
- omlish/__about__.py +15 -15
- omlish/argparse/all.py +17 -9
- omlish/argparse/cli.py +16 -3
- omlish/argparse/utils.py +21 -0
- omlish/asyncs/asyncio/rlock.py +110 -0
- omlish/asyncs/asyncio/sync.py +43 -0
- omlish/asyncs/asyncio/utils.py +2 -0
- omlish/asyncs/sync.py +25 -0
- omlish/bootstrap/_marshal.py +1 -1
- omlish/bootstrap/diag.py +12 -21
- omlish/bootstrap/main.py +2 -5
- omlish/bootstrap/sys.py +27 -28
- omlish/cexts/__init__.py +0 -0
- omlish/cexts/include/omlish/omlish.hh +1 -0
- omlish/collections/__init__.py +13 -1
- omlish/collections/attrregistry.py +210 -0
- omlish/collections/cache/impl.py +1 -0
- omlish/collections/identity.py +1 -0
- omlish/collections/mappings.py +28 -0
- omlish/collections/trie.py +5 -1
- omlish/collections/utils.py +77 -0
- omlish/concurrent/all.py +2 -1
- omlish/concurrent/futures.py +25 -0
- omlish/concurrent/threadlets.py +1 -1
- omlish/daemons/reparent.py +2 -3
- omlish/daemons/spawning.py +2 -3
- omlish/dataclasses/__init__.py +2 -0
- omlish/dataclasses/impl/api/classes/decorator.py +3 -0
- omlish/dataclasses/impl/api/classes/make.py +3 -0
- omlish/dataclasses/impl/concerns/repr.py +15 -2
- omlish/dataclasses/impl/configs.py +97 -37
- omlish/dataclasses/impl/generation/compilation.py +21 -19
- omlish/dataclasses/impl/generation/globals.py +1 -0
- omlish/dataclasses/impl/generation/ops.py +1 -0
- omlish/dataclasses/impl/generation/processor.py +105 -24
- omlish/dataclasses/impl/processing/base.py +8 -0
- omlish/dataclasses/impl/processing/driving.py +8 -8
- omlish/dataclasses/specs.py +1 -0
- omlish/dataclasses/tools/modifiers.py +5 -0
- omlish/diag/cmds/__init__.py +0 -0
- omlish/diag/{lslocks.py → cmds/lslocks.py} +6 -6
- omlish/diag/{lsof.py → cmds/lsof.py} +6 -6
- omlish/diag/{ps.py → cmds/ps.py} +6 -6
- omlish/diag/pycharm.py +16 -2
- omlish/diag/pydevd.py +58 -40
- omlish/diag/replserver/console.py +1 -1
- omlish/dispatch/__init__.py +18 -12
- omlish/dispatch/methods.py +50 -140
- omlish/dom/rendering.py +1 -1
- omlish/formats/dotenv.py +1 -1
- omlish/formats/json/stream/__init__.py +13 -0
- omlish/funcs/guard.py +225 -0
- omlish/graphs/dot/rendering.py +1 -1
- omlish/http/all.py +44 -4
- omlish/http/clients/asyncs.py +33 -27
- omlish/http/clients/base.py +17 -1
- omlish/http/clients/coro/__init__.py +0 -0
- omlish/http/clients/coro/sync.py +171 -0
- omlish/http/clients/default.py +208 -29
- omlish/http/clients/executor.py +56 -0
- omlish/http/clients/httpx.py +72 -11
- omlish/http/clients/middleware.py +181 -0
- omlish/http/clients/sync.py +33 -27
- omlish/http/clients/syncasync.py +49 -0
- omlish/http/clients/urllib.py +6 -3
- omlish/http/coro/client/connection.py +15 -6
- omlish/http/coro/io.py +2 -0
- omlish/http/flasky/__init__.py +40 -0
- omlish/http/flasky/_compat.py +2 -0
- omlish/http/flasky/api.py +82 -0
- omlish/http/flasky/app.py +203 -0
- omlish/http/flasky/cvs.py +59 -0
- omlish/http/flasky/requests.py +20 -0
- omlish/http/flasky/responses.py +23 -0
- omlish/http/flasky/routes.py +23 -0
- omlish/http/flasky/types.py +15 -0
- omlish/http/urls.py +67 -0
- omlish/inject/__init__.py +38 -18
- omlish/inject/_dataclasses.py +4986 -0
- omlish/inject/binder.py +4 -48
- omlish/inject/elements.py +27 -0
- omlish/inject/helpers/__init__.py +0 -0
- omlish/inject/{utils.py → helpers/constfn.py} +3 -3
- omlish/inject/{tags.py → helpers/id.py} +2 -2
- omlish/inject/helpers/multis.py +143 -0
- omlish/inject/helpers/wrappers.py +54 -0
- omlish/inject/impl/elements.py +47 -17
- omlish/inject/impl/injector.py +20 -19
- omlish/inject/impl/inspect.py +10 -1
- omlish/inject/impl/maysync.py +3 -4
- omlish/inject/impl/multis.py +3 -0
- omlish/inject/impl/sync.py +3 -4
- omlish/inject/injector.py +31 -2
- omlish/inject/inspect.py +35 -0
- omlish/inject/maysync.py +2 -4
- omlish/inject/multis.py +8 -0
- omlish/inject/overrides.py +3 -3
- omlish/inject/privates.py +6 -0
- omlish/inject/providers.py +3 -2
- omlish/inject/sync.py +5 -4
- omlish/io/buffers.py +118 -0
- omlish/io/readers.py +29 -0
- omlish/iterators/transforms.py +2 -2
- omlish/lang/__init__.py +178 -97
- omlish/lang/_asyncs.cc +186 -0
- omlish/lang/asyncs.py +17 -0
- omlish/lang/casing.py +11 -0
- omlish/lang/contextmanagers.py +28 -4
- omlish/lang/functions.py +31 -22
- omlish/lang/imports/_capture.cc +11 -9
- omlish/lang/imports/capture.py +363 -170
- omlish/lang/imports/proxy.py +455 -152
- omlish/lang/lazyglobals.py +22 -9
- omlish/lang/params.py +17 -0
- omlish/lang/recursion.py +0 -1
- omlish/lang/sequences.py +124 -0
- omlish/lite/abstract.py +54 -24
- omlish/lite/asyncs.py +2 -2
- omlish/lite/attrops.py +2 -0
- omlish/lite/contextmanagers.py +4 -4
- omlish/lite/dataclasses.py +44 -0
- omlish/lite/maybes.py +8 -0
- omlish/lite/maysync.py +1 -5
- omlish/lite/pycharm.py +1 -1
- omlish/lite/typing.py +6 -0
- omlish/logs/all.py +1 -1
- omlish/logs/utils.py +1 -1
- omlish/manifests/loading.py +2 -1
- omlish/marshal/__init__.py +33 -13
- omlish/marshal/_dataclasses.py +2774 -0
- omlish/marshal/base/configs.py +12 -0
- omlish/marshal/base/contexts.py +36 -21
- omlish/marshal/base/funcs.py +8 -11
- omlish/marshal/base/options.py +8 -0
- omlish/marshal/base/registries.py +146 -44
- omlish/marshal/base/types.py +40 -16
- omlish/marshal/composite/iterables.py +33 -20
- omlish/marshal/composite/literals.py +20 -18
- omlish/marshal/composite/mappings.py +36 -23
- omlish/marshal/composite/maybes.py +29 -19
- omlish/marshal/composite/newtypes.py +16 -16
- omlish/marshal/composite/optionals.py +14 -14
- omlish/marshal/composite/special.py +15 -15
- omlish/marshal/composite/unions/__init__.py +0 -0
- omlish/marshal/composite/unions/literals.py +93 -0
- omlish/marshal/composite/unions/primitives.py +103 -0
- omlish/marshal/factories/invalidate.py +18 -68
- omlish/marshal/factories/method.py +26 -0
- omlish/marshal/factories/moduleimport/factories.py +22 -65
- omlish/marshal/factories/multi.py +13 -25
- omlish/marshal/factories/recursive.py +42 -56
- omlish/marshal/factories/typecache.py +29 -74
- omlish/marshal/factories/typemap.py +42 -43
- omlish/marshal/objects/dataclasses.py +129 -106
- omlish/marshal/objects/marshal.py +18 -14
- omlish/marshal/objects/namedtuples.py +48 -42
- omlish/marshal/objects/unmarshal.py +19 -15
- omlish/marshal/polymorphism/marshal.py +9 -11
- omlish/marshal/polymorphism/metadata.py +16 -5
- omlish/marshal/polymorphism/standard.py +13 -1
- omlish/marshal/polymorphism/unions.py +15 -105
- omlish/marshal/polymorphism/unmarshal.py +9 -10
- omlish/marshal/singular/enums.py +14 -18
- omlish/marshal/standard.py +10 -6
- omlish/marshal/trivial/any.py +1 -1
- omlish/marshal/trivial/forbidden.py +21 -26
- omlish/metadata.py +23 -1
- omlish/os/forkhooks.py +4 -0
- omlish/os/pidfiles/pinning.py +2 -2
- omlish/reflect/types.py +1 -0
- omlish/secrets/marshal.py +1 -1
- omlish/specs/jmespath/__init__.py +12 -3
- omlish/specs/jmespath/_dataclasses.py +2893 -0
- omlish/specs/jmespath/ast.py +1 -1
- omlish/specs/jsonrpc/__init__.py +13 -0
- omlish/specs/jsonrpc/_marshal.py +32 -23
- omlish/specs/jsonrpc/conns.py +10 -7
- omlish/specs/jsonschema/_marshal.py +1 -1
- omlish/specs/jsonschema/keywords/__init__.py +7 -0
- omlish/specs/jsonschema/keywords/_dataclasses.py +1644 -0
- omlish/specs/openapi/_marshal.py +31 -22
- omlish/sql/{tabledefs/alchemy.py → alchemy/tabledefs.py} +2 -2
- omlish/sql/queries/_marshal.py +2 -2
- omlish/sql/queries/rendering.py +1 -1
- omlish/sql/tabledefs/_marshal.py +1 -1
- omlish/subprocesses/base.py +4 -0
- omlish/subprocesses/editor.py +1 -1
- omlish/sync.py +155 -21
- omlish/term/alt.py +60 -0
- omlish/term/confirm.py +8 -8
- omlish/term/pager.py +235 -0
- omlish/term/terminfo.py +935 -0
- omlish/term/termstate.py +67 -0
- omlish/term/vt100/terminal.py +0 -3
- omlish/testing/pytest/plugins/asyncs/fixtures.py +4 -1
- omlish/testing/pytest/plugins/skips.py +2 -1
- omlish/testing/unittest/main.py +3 -3
- omlish/text/docwrap/__init__.py +3 -0
- omlish/text/docwrap/__main__.py +11 -0
- omlish/text/docwrap/api.py +83 -0
- omlish/text/docwrap/cli.py +86 -0
- omlish/text/docwrap/groups.py +84 -0
- omlish/text/docwrap/lists.py +167 -0
- omlish/text/docwrap/parts.py +146 -0
- omlish/text/docwrap/reflowing.py +106 -0
- omlish/text/docwrap/rendering.py +151 -0
- omlish/text/docwrap/utils.py +11 -0
- omlish/text/docwrap/wrapping.py +59 -0
- omlish/text/filecache.py +2 -2
- omlish/text/lorem.py +6 -0
- omlish/text/parts.py +2 -2
- omlish/text/textwrap.py +51 -0
- omlish/typedvalues/marshal.py +85 -59
- omlish/typedvalues/values.py +2 -1
- {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev484.dist-info}/METADATA +29 -28
- {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev484.dist-info}/RECORD +222 -171
- omlish/dataclasses/impl/generation/mangling.py +0 -18
- omlish/funcs/match.py +0 -227
- omlish/marshal/factories/match.py +0 -34
- omlish/marshal/factories/simple.py +0 -28
- /omlish/inject/impl/{providers2.py → providersmap.py} +0 -0
- {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev484.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev484.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev484.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev484.dist-info}/top_level.txt +0 -0
omlish/lang/__init__.py
CHANGED
|
@@ -9,6 +9,8 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
9
9
|
|
|
10
10
|
AsyncGeneratorWithReturn,
|
|
11
11
|
async_generator_with_return,
|
|
12
|
+
|
|
13
|
+
sync_await,
|
|
12
14
|
)
|
|
13
15
|
|
|
14
16
|
from .attrstorage import ( # noqa
|
|
@@ -63,15 +65,20 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
63
65
|
snake_case,
|
|
64
66
|
up_snake_case,
|
|
65
67
|
|
|
68
|
+
camel_to_snake,
|
|
69
|
+
snake_to_camel,
|
|
70
|
+
|
|
66
71
|
get_string_casing,
|
|
67
72
|
split_string_casing,
|
|
68
73
|
)
|
|
69
74
|
|
|
70
75
|
from .classes.abstract import ( # noqa
|
|
71
|
-
get_abstracts,
|
|
72
|
-
is_abstract,
|
|
73
|
-
is_abstract_class,
|
|
74
76
|
is_abstract_method,
|
|
77
|
+
|
|
78
|
+
is_abstract_class,
|
|
79
|
+
is_abstract,
|
|
80
|
+
|
|
81
|
+
get_abstracts,
|
|
75
82
|
make_abstract,
|
|
76
83
|
)
|
|
77
84
|
|
|
@@ -81,8 +88,8 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
81
88
|
|
|
82
89
|
from .classes.namespaces import ( # noqa
|
|
83
90
|
GenericNamespaceMeta,
|
|
84
|
-
Namespace,
|
|
85
91
|
NamespaceMeta,
|
|
92
|
+
Namespace,
|
|
86
93
|
)
|
|
87
94
|
|
|
88
95
|
from .classes.protocols import ( # noqa
|
|
@@ -91,54 +98,65 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
91
98
|
)
|
|
92
99
|
|
|
93
100
|
from .classes.restrict import ( # noqa
|
|
94
|
-
AnySensitive,
|
|
95
|
-
Final,
|
|
96
101
|
FinalTypeError,
|
|
97
|
-
|
|
102
|
+
Final,
|
|
103
|
+
|
|
104
|
+
SealedError,
|
|
105
|
+
Sealed,
|
|
106
|
+
PackageSealed,
|
|
107
|
+
|
|
98
108
|
NotInstantiable,
|
|
99
109
|
NotPicklable,
|
|
100
|
-
|
|
110
|
+
|
|
111
|
+
NoBool,
|
|
112
|
+
no_bool,
|
|
113
|
+
|
|
101
114
|
SENSITIVE_ATTR,
|
|
102
|
-
Sealed,
|
|
103
|
-
SealedError,
|
|
104
115
|
Sensitive,
|
|
105
|
-
|
|
116
|
+
AnySensitive,
|
|
106
117
|
)
|
|
107
118
|
|
|
108
119
|
from .classes.simple import ( # noqa
|
|
109
|
-
LazySingleton,
|
|
110
|
-
Marker,
|
|
111
120
|
SimpleMetaDict,
|
|
121
|
+
|
|
122
|
+
Marker,
|
|
123
|
+
|
|
112
124
|
Singleton,
|
|
125
|
+
LazySingleton,
|
|
113
126
|
)
|
|
114
127
|
|
|
115
128
|
from .classes.virtual import ( # noqa
|
|
116
|
-
Callable,
|
|
117
|
-
Descriptor,
|
|
118
|
-
Picklable,
|
|
119
129
|
Virtual,
|
|
120
130
|
virtual_check,
|
|
131
|
+
|
|
132
|
+
Descriptor,
|
|
133
|
+
Picklable,
|
|
134
|
+
|
|
135
|
+
Callable,
|
|
121
136
|
)
|
|
122
137
|
|
|
123
138
|
from .clsdct import ( # noqa
|
|
139
|
+
is_possibly_cls_dct,
|
|
140
|
+
get_caller_cls_dct,
|
|
141
|
+
|
|
124
142
|
ClassDctFn,
|
|
125
143
|
cls_dct_fn,
|
|
126
|
-
get_caller_cls_dct,
|
|
127
|
-
is_possibly_cls_dct,
|
|
128
144
|
)
|
|
129
145
|
|
|
130
146
|
from .collections import ( # noqa
|
|
131
|
-
empty_map,
|
|
132
|
-
merge_dicts,
|
|
133
147
|
yield_dict_init,
|
|
148
|
+
merge_dicts,
|
|
149
|
+
|
|
150
|
+
empty_map,
|
|
134
151
|
)
|
|
135
152
|
|
|
136
153
|
from .comparison import ( # noqa
|
|
137
|
-
|
|
154
|
+
cmp,
|
|
155
|
+
|
|
138
156
|
InfinityType,
|
|
139
|
-
|
|
157
|
+
Infinity,
|
|
140
158
|
NegativeInfinityType,
|
|
141
|
-
|
|
159
|
+
NegativeInfinity,
|
|
142
160
|
)
|
|
143
161
|
|
|
144
162
|
from .contextmanagers import ( # noqa
|
|
@@ -158,6 +176,7 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
158
176
|
|
|
159
177
|
maybe_managing,
|
|
160
178
|
async_maybe_managing,
|
|
179
|
+
async_or_sync_maybe_managing,
|
|
161
180
|
|
|
162
181
|
disposing,
|
|
163
182
|
breakpoint_on_exception,
|
|
@@ -181,6 +200,9 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
181
200
|
|
|
182
201
|
call_with_exit_stack,
|
|
183
202
|
call_with_async_exit_stack,
|
|
203
|
+
|
|
204
|
+
with_exit_stack,
|
|
205
|
+
with_async_exit_stack,
|
|
184
206
|
)
|
|
185
207
|
|
|
186
208
|
from .datetimes import ( # noqa
|
|
@@ -194,19 +216,26 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
194
216
|
)
|
|
195
217
|
|
|
196
218
|
from .descriptors import ( # noqa
|
|
197
|
-
AccessForbiddenError,
|
|
198
|
-
access_forbidden,
|
|
199
219
|
attr_property,
|
|
200
|
-
classonly,
|
|
201
|
-
decorator,
|
|
202
|
-
is_method_descriptor,
|
|
203
220
|
item_property,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
unwrap_func,
|
|
207
|
-
unwrap_func_with_partials,
|
|
221
|
+
|
|
222
|
+
is_method_descriptor,
|
|
208
223
|
unwrap_method_descriptors,
|
|
224
|
+
|
|
225
|
+
unwrap_func_with_partials,
|
|
226
|
+
unwrap_func,
|
|
227
|
+
|
|
228
|
+
unwrap_callable_with_partials,
|
|
229
|
+
unwrap_callable,
|
|
230
|
+
|
|
209
231
|
update_wrapper,
|
|
232
|
+
|
|
233
|
+
decorator,
|
|
234
|
+
|
|
235
|
+
AccessForbiddenError,
|
|
236
|
+
access_forbidden,
|
|
237
|
+
|
|
238
|
+
classonly,
|
|
210
239
|
)
|
|
211
240
|
|
|
212
241
|
from .enums import ( # noqa
|
|
@@ -218,43 +247,58 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
218
247
|
)
|
|
219
248
|
|
|
220
249
|
from .functions import ( # noqa
|
|
221
|
-
|
|
250
|
+
is_lambda,
|
|
251
|
+
|
|
222
252
|
call_with,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
253
|
+
opt_call,
|
|
254
|
+
opt_fn,
|
|
255
|
+
recurse,
|
|
256
|
+
|
|
257
|
+
raise_,
|
|
258
|
+
raising,
|
|
259
|
+
try_,
|
|
226
260
|
finally_,
|
|
261
|
+
|
|
227
262
|
identity,
|
|
228
|
-
|
|
263
|
+
constant,
|
|
264
|
+
nullary_constant,
|
|
265
|
+
|
|
229
266
|
is_none,
|
|
230
267
|
is_not_none,
|
|
231
268
|
isinstance_of,
|
|
232
269
|
issubclass_of,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
270
|
+
strict_eq,
|
|
271
|
+
|
|
272
|
+
VoidError,
|
|
273
|
+
Void,
|
|
274
|
+
void,
|
|
275
|
+
|
|
276
|
+
periodically,
|
|
277
|
+
|
|
278
|
+
opt_getattr,
|
|
279
|
+
coalesce,
|
|
237
280
|
opt_coalesce,
|
|
238
|
-
|
|
281
|
+
|
|
282
|
+
cond_kw,
|
|
239
283
|
opt_kw,
|
|
240
|
-
periodically,
|
|
241
|
-
raise_,
|
|
242
|
-
raising,
|
|
243
|
-
recurse,
|
|
244
|
-
strict_eq,
|
|
245
284
|
truthy_kw,
|
|
246
|
-
|
|
247
|
-
|
|
285
|
+
|
|
286
|
+
new_function,
|
|
287
|
+
new_function_kwargs,
|
|
288
|
+
copy_function,
|
|
248
289
|
)
|
|
249
290
|
|
|
250
291
|
from .generators import ( # noqa
|
|
251
|
-
|
|
252
|
-
GeneratorMappedIterator,
|
|
292
|
+
nextgen,
|
|
253
293
|
autostart,
|
|
254
|
-
|
|
294
|
+
|
|
295
|
+
GeneratorLike,
|
|
296
|
+
|
|
255
297
|
capture_generator,
|
|
298
|
+
capture_coroutine,
|
|
299
|
+
|
|
300
|
+
GeneratorMappedIterator,
|
|
256
301
|
genmap,
|
|
257
|
-
nextgen,
|
|
258
302
|
)
|
|
259
303
|
|
|
260
304
|
from .imports.capture import ( # noqa
|
|
@@ -294,21 +338,26 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
294
338
|
)
|
|
295
339
|
|
|
296
340
|
from .iterables import ( # noqa
|
|
297
|
-
IteratorWithReturn,
|
|
298
|
-
asrange,
|
|
299
|
-
chunk,
|
|
300
|
-
common_prefix_len,
|
|
301
|
-
consume,
|
|
302
|
-
flatmap,
|
|
303
|
-
flatten,
|
|
304
341
|
ilen,
|
|
342
|
+
take,
|
|
343
|
+
consume,
|
|
344
|
+
peek,
|
|
345
|
+
chunk,
|
|
305
346
|
interleave,
|
|
347
|
+
renumerate,
|
|
348
|
+
common_prefix_len,
|
|
349
|
+
|
|
350
|
+
readiter,
|
|
351
|
+
|
|
306
352
|
itergen,
|
|
307
|
-
|
|
353
|
+
|
|
354
|
+
flatten,
|
|
355
|
+
flatmap,
|
|
356
|
+
|
|
357
|
+
asrange,
|
|
308
358
|
prodrange,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
take,
|
|
359
|
+
|
|
360
|
+
IteratorWithReturn,
|
|
312
361
|
)
|
|
313
362
|
|
|
314
363
|
from .lazyglobals import ( # noqa
|
|
@@ -330,27 +379,38 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
330
379
|
)
|
|
331
380
|
|
|
332
381
|
from .objects import ( # noqa
|
|
333
|
-
Identity,
|
|
334
|
-
SimpleProxy,
|
|
335
|
-
anon_object,
|
|
336
382
|
arg_repr,
|
|
383
|
+
opt_repr,
|
|
384
|
+
|
|
337
385
|
can_weakref,
|
|
338
|
-
|
|
386
|
+
|
|
339
387
|
new_type,
|
|
340
|
-
opt_repr,
|
|
341
388
|
super_meta,
|
|
389
|
+
|
|
390
|
+
deep_subclasses,
|
|
391
|
+
|
|
392
|
+
SimpleProxy,
|
|
393
|
+
|
|
394
|
+
anon_object,
|
|
395
|
+
|
|
396
|
+
Identity,
|
|
342
397
|
)
|
|
343
398
|
|
|
344
399
|
from .outcomes import ( # noqa
|
|
345
|
-
Either,
|
|
346
|
-
Error,
|
|
347
|
-
Outcome,
|
|
348
400
|
OutcomeAlreadyUnwrappedError,
|
|
349
|
-
|
|
350
|
-
acapture,
|
|
401
|
+
|
|
351
402
|
capture,
|
|
352
|
-
|
|
403
|
+
acapture,
|
|
404
|
+
|
|
405
|
+
Outcome,
|
|
406
|
+
|
|
407
|
+
Value,
|
|
353
408
|
value,
|
|
409
|
+
|
|
410
|
+
Error,
|
|
411
|
+
error,
|
|
412
|
+
|
|
413
|
+
Either,
|
|
354
414
|
)
|
|
355
415
|
|
|
356
416
|
from .overrides import ( # noqa
|
|
@@ -363,29 +423,37 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
363
423
|
)
|
|
364
424
|
|
|
365
425
|
from .params import ( # noqa
|
|
426
|
+
CanParamSpec,
|
|
427
|
+
|
|
428
|
+
Param,
|
|
429
|
+
|
|
430
|
+
VarParam,
|
|
366
431
|
ArgsParam,
|
|
367
|
-
KwOnlyParam,
|
|
368
432
|
KwargsParam,
|
|
369
|
-
|
|
433
|
+
|
|
434
|
+
ValParam,
|
|
435
|
+
PosOnlyParam,
|
|
436
|
+
KwOnlyParam,
|
|
437
|
+
|
|
370
438
|
ParamSeparator,
|
|
439
|
+
|
|
371
440
|
ParamSpec,
|
|
372
|
-
|
|
373
|
-
ValParam,
|
|
374
|
-
VarParam,
|
|
441
|
+
|
|
375
442
|
param_render,
|
|
376
443
|
)
|
|
377
444
|
|
|
378
445
|
from .recursion import ( # noqa
|
|
379
446
|
LimitedRecursionError,
|
|
380
|
-
recursion_limiting,
|
|
381
447
|
recursion_limiting_context,
|
|
448
|
+
|
|
449
|
+
recursion_limiting,
|
|
382
450
|
)
|
|
383
451
|
|
|
384
452
|
from .resolving import ( # noqa
|
|
385
|
-
Resolvable,
|
|
386
453
|
ResolvableClassNameError,
|
|
387
454
|
get_cls_fqcn,
|
|
388
455
|
get_fqcn_cls,
|
|
456
|
+
Resolvable,
|
|
389
457
|
)
|
|
390
458
|
|
|
391
459
|
from .resources import ( # noqa
|
|
@@ -394,25 +462,39 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
394
462
|
get_relative_resources,
|
|
395
463
|
)
|
|
396
464
|
|
|
465
|
+
from .sequences import ( # noqa
|
|
466
|
+
iterslice,
|
|
467
|
+
iterrange,
|
|
468
|
+
|
|
469
|
+
SeqView,
|
|
470
|
+
)
|
|
471
|
+
|
|
397
472
|
from .strings import ( # noqa
|
|
398
|
-
BOOL_FALSE_STRINGS,
|
|
399
|
-
BOOL_STRINGS,
|
|
400
|
-
BOOL_TRUE_STRINGS,
|
|
401
|
-
STRING_BOOL_VALUES,
|
|
402
|
-
find_any,
|
|
403
|
-
indent_lines,
|
|
404
|
-
is_dunder,
|
|
405
|
-
is_ident,
|
|
406
|
-
is_ident_cont,
|
|
407
|
-
is_ident_start,
|
|
408
|
-
is_sunder,
|
|
409
|
-
iter_pat,
|
|
410
473
|
prefix_delimited,
|
|
411
474
|
prefix_lines,
|
|
412
|
-
|
|
413
|
-
|
|
475
|
+
indent_lines,
|
|
476
|
+
|
|
414
477
|
strip_prefix,
|
|
415
478
|
strip_suffix,
|
|
479
|
+
|
|
480
|
+
replace_many,
|
|
481
|
+
|
|
482
|
+
find_any,
|
|
483
|
+
rfind_any,
|
|
484
|
+
|
|
485
|
+
is_dunder,
|
|
486
|
+
is_sunder,
|
|
487
|
+
|
|
488
|
+
is_ident_start,
|
|
489
|
+
is_ident_cont,
|
|
490
|
+
is_ident,
|
|
491
|
+
|
|
492
|
+
BOOL_STRINGS,
|
|
493
|
+
BOOL_FALSE_STRINGS,
|
|
494
|
+
BOOL_TRUE_STRINGS,
|
|
495
|
+
STRING_BOOL_VALUES,
|
|
496
|
+
|
|
497
|
+
iter_pat,
|
|
416
498
|
)
|
|
417
499
|
|
|
418
500
|
from .sys import ( # noqa
|
|
@@ -456,7 +538,6 @@ with _auto_proxy_init(globals(), update_exports=True):
|
|
|
456
538
|
async_enumerate,
|
|
457
539
|
|
|
458
540
|
SyncAwaitCoroutineNotTerminatedError,
|
|
459
|
-
sync_await,
|
|
460
541
|
|
|
461
542
|
sync_aiter,
|
|
462
543
|
sync_async_list,
|
omlish/lang/_asyncs.cc
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// @omlish-cext
|
|
2
|
+
#define PY_SSIZE_T_CLEAN
|
|
3
|
+
#include <Python.h>
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
#define _MODULE_NAME "_asyncs"
|
|
8
|
+
#define _PACKAGE_NAME "omlish.lang"
|
|
9
|
+
#define _MODULE_FULL_NAME _PACKAGE_NAME "." _MODULE_NAME
|
|
10
|
+
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
typedef struct {
|
|
14
|
+
PyObject *SyncAwaitCoroutineNotTerminatedError;
|
|
15
|
+
PyObject *str_close;
|
|
16
|
+
PyObject *str___await__;
|
|
17
|
+
} module_state;
|
|
18
|
+
|
|
19
|
+
static module_state *
|
|
20
|
+
get_module_state(PyObject *module)
|
|
21
|
+
{
|
|
22
|
+
return (module_state *) PyModule_GetState(module);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
static void
|
|
28
|
+
suppress_close(PyObject *iter, module_state *state)
|
|
29
|
+
{
|
|
30
|
+
PyObject *res = PyObject_CallMethodNoArgs(iter, state->str_close);
|
|
31
|
+
if (!res) {
|
|
32
|
+
PyErr_Clear();
|
|
33
|
+
} else {
|
|
34
|
+
Py_DECREF(res);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static PyObject *
|
|
39
|
+
sync_await(PyObject *module, PyObject *aw)
|
|
40
|
+
{
|
|
41
|
+
module_state *state = get_module_state(module);
|
|
42
|
+
PyObject *await_meth = NULL;
|
|
43
|
+
PyObject *iter = NULL;
|
|
44
|
+
PyObject *result = NULL;
|
|
45
|
+
PySendResult sres;
|
|
46
|
+
|
|
47
|
+
await_meth = PyObject_GetAttr(aw, state->str___await__);
|
|
48
|
+
if (await_meth == NULL) {
|
|
49
|
+
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
|
50
|
+
PyErr_SetString(PyExc_TypeError, "object is not awaitable (no __await__)");
|
|
51
|
+
}
|
|
52
|
+
goto error;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
iter = PyObject_CallNoArgs(await_meth);
|
|
56
|
+
Py_DECREF(await_meth);
|
|
57
|
+
await_meth = NULL;
|
|
58
|
+
|
|
59
|
+
if (iter == NULL) {
|
|
60
|
+
goto error;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!PyIter_Check(iter)) {
|
|
64
|
+
Py_DECREF(iter);
|
|
65
|
+
PyErr_SetString(PyExc_TypeError, "__await__() must return an iterator");
|
|
66
|
+
goto error;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
sres = PyIter_Send(iter, Py_None, &result);
|
|
70
|
+
if (sres == PYGEN_ERROR) {
|
|
71
|
+
Py_DECREF(iter);
|
|
72
|
+
goto error;
|
|
73
|
+
}
|
|
74
|
+
if (sres == PYGEN_NEXT) {
|
|
75
|
+
Py_XDECREF(result);
|
|
76
|
+
suppress_close(iter, state);
|
|
77
|
+
Py_DECREF(iter);
|
|
78
|
+
PyErr_SetString(state->SyncAwaitCoroutineNotTerminatedError, "Not terminated");
|
|
79
|
+
goto error;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
Py_DECREF(iter);
|
|
83
|
+
return result;
|
|
84
|
+
|
|
85
|
+
error:
|
|
86
|
+
return NULL;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//
|
|
90
|
+
|
|
91
|
+
static PyMethodDef mod_methods[] = {
|
|
92
|
+
{"sync_await", sync_await, METH_O, "sync_await"},
|
|
93
|
+
{NULL, NULL, 0, NULL}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
static int
|
|
97
|
+
module_traverse(PyObject *module, visitproc visit, void *arg)
|
|
98
|
+
{
|
|
99
|
+
module_state *state = get_module_state(module);
|
|
100
|
+
Py_VISIT(state->SyncAwaitCoroutineNotTerminatedError);
|
|
101
|
+
Py_VISIT(state->str_close);
|
|
102
|
+
Py_VISIT(state->str___await__);
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static int
|
|
107
|
+
module_clear(PyObject *module)
|
|
108
|
+
{
|
|
109
|
+
module_state *state = get_module_state(module);
|
|
110
|
+
Py_CLEAR(state->SyncAwaitCoroutineNotTerminatedError);
|
|
111
|
+
Py_CLEAR(state->str_close);
|
|
112
|
+
Py_CLEAR(state->str___await__);
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static void
|
|
117
|
+
module_free(void *module)
|
|
118
|
+
{
|
|
119
|
+
module_clear((PyObject *) module);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static int
|
|
123
|
+
module_exec(PyObject *module)
|
|
124
|
+
{
|
|
125
|
+
module_state *state = get_module_state(module);
|
|
126
|
+
|
|
127
|
+
state->str_close = PyUnicode_InternFromString("close");
|
|
128
|
+
if (!state->str_close) {
|
|
129
|
+
return -1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
state->str___await__ = PyUnicode_InternFromString("__await__");
|
|
133
|
+
if (!state->str___await__) {
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
PyObject *asyncs_module = PyImport_ImportModule("omlish.lite.asyncs");
|
|
138
|
+
if (!asyncs_module) {
|
|
139
|
+
return -1;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
state->SyncAwaitCoroutineNotTerminatedError = PyObject_GetAttrString(
|
|
143
|
+
asyncs_module,
|
|
144
|
+
"SyncAwaitCoroutineNotTerminatedError"
|
|
145
|
+
);
|
|
146
|
+
Py_DECREF(asyncs_module);
|
|
147
|
+
|
|
148
|
+
if (!state->SyncAwaitCoroutineNotTerminatedError) {
|
|
149
|
+
return -1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//
|
|
156
|
+
|
|
157
|
+
PyDoc_STRVAR(module_doc, _MODULE_NAME);
|
|
158
|
+
|
|
159
|
+
static PyModuleDef_Slot module_slots[] = {
|
|
160
|
+
{Py_mod_exec, (void *) module_exec},
|
|
161
|
+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
|
|
162
|
+
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
|
|
163
|
+
{0, NULL}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
static PyModuleDef module_def = {
|
|
167
|
+
.m_base = PyModuleDef_HEAD_INIT,
|
|
168
|
+
.m_name = _MODULE_NAME,
|
|
169
|
+
.m_doc = module_doc,
|
|
170
|
+
.m_size = sizeof(module_state),
|
|
171
|
+
.m_methods = mod_methods,
|
|
172
|
+
.m_slots = module_slots,
|
|
173
|
+
.m_traverse = module_traverse,
|
|
174
|
+
.m_clear = module_clear,
|
|
175
|
+
.m_free = module_free,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
extern "C" {
|
|
179
|
+
|
|
180
|
+
PyMODINIT_FUNC
|
|
181
|
+
PyInit__asyncs(void)
|
|
182
|
+
{
|
|
183
|
+
return PyModuleDef_Init(&module_def);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
omlish/lang/asyncs.py
CHANGED
|
@@ -3,6 +3,7 @@ import functools
|
|
|
3
3
|
import typing as ta
|
|
4
4
|
|
|
5
5
|
from ..lite.abstract import Abstract
|
|
6
|
+
from ..lite.asyncs import sync_await as _sync_await
|
|
6
7
|
from ..lite.maybes import Maybe
|
|
7
8
|
|
|
8
9
|
|
|
@@ -78,3 +79,19 @@ def async_generator_with_return(
|
|
|
78
79
|
return (x := _AsyncGeneratorWithReturn(fn(set_value, *args, **kwargs))) # type: ignore[var-annotated]
|
|
79
80
|
|
|
80
81
|
return inner
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
##
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
sync_await = _sync_await
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
from . import _asyncs as cext # type: ignore
|
|
92
|
+
|
|
93
|
+
except ImportError:
|
|
94
|
+
pass
|
|
95
|
+
|
|
96
|
+
else:
|
|
97
|
+
sync_await = cext.sync_await
|
omlish/lang/casing.py
CHANGED
|
@@ -50,6 +50,13 @@ class StringCasing(Abstract):
|
|
|
50
50
|
|
|
51
51
|
raise NotImplementedError
|
|
52
52
|
|
|
53
|
+
#
|
|
54
|
+
|
|
55
|
+
def to(self, other: 'StringCasing') -> ta.Callable[[str], str]:
|
|
56
|
+
def inner(s: str) -> str:
|
|
57
|
+
return other.join(*self.split(s))
|
|
58
|
+
return inner
|
|
59
|
+
|
|
53
60
|
|
|
54
61
|
#
|
|
55
62
|
|
|
@@ -167,6 +174,10 @@ snake_case = SNAKE_CASE.join
|
|
|
167
174
|
up_snake_case = UP_SNAKE_CASE.join
|
|
168
175
|
|
|
169
176
|
|
|
177
|
+
camel_to_snake = CAMEL_CASE.to(SNAKE_CASE)
|
|
178
|
+
snake_to_camel = SNAKE_CASE.to(CAMEL_CASE)
|
|
179
|
+
|
|
180
|
+
|
|
170
181
|
##
|
|
171
182
|
|
|
172
183
|
|