omlish 0.0.0.dev447__py3-none-any.whl → 0.0.0.dev493__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.

Files changed (265) hide show
  1. omlish/.omlish-manifests.json +12 -0
  2. omlish/README.md +199 -0
  3. omlish/__about__.py +21 -16
  4. omlish/argparse/all.py +17 -9
  5. omlish/argparse/cli.py +16 -3
  6. omlish/argparse/utils.py +21 -0
  7. omlish/asyncs/asyncio/rlock.py +110 -0
  8. omlish/asyncs/asyncio/sync.py +43 -0
  9. omlish/asyncs/asyncio/utils.py +2 -0
  10. omlish/asyncs/sync.py +25 -0
  11. omlish/bootstrap/_marshal.py +1 -1
  12. omlish/bootstrap/diag.py +12 -21
  13. omlish/bootstrap/main.py +2 -5
  14. omlish/bootstrap/sys.py +27 -28
  15. omlish/cexts/__init__.py +0 -0
  16. omlish/cexts/include/omlish/omlish.hh +1 -0
  17. omlish/collections/__init__.py +13 -1
  18. omlish/collections/attrregistry.py +210 -0
  19. omlish/collections/cache/impl.py +1 -0
  20. omlish/collections/identity.py +1 -0
  21. omlish/collections/mappings.py +28 -0
  22. omlish/collections/trie.py +5 -1
  23. omlish/collections/utils.py +77 -0
  24. omlish/concurrent/all.py +2 -1
  25. omlish/concurrent/futures.py +25 -0
  26. omlish/concurrent/threadlets.py +1 -1
  27. omlish/daemons/reparent.py +2 -3
  28. omlish/daemons/spawning.py +2 -3
  29. omlish/dataclasses/__init__.py +2 -0
  30. omlish/dataclasses/impl/api/classes/decorator.py +3 -0
  31. omlish/dataclasses/impl/api/classes/make.py +3 -0
  32. omlish/dataclasses/impl/concerns/repr.py +15 -2
  33. omlish/dataclasses/impl/configs.py +97 -37
  34. omlish/dataclasses/impl/generation/compilation.py +21 -19
  35. omlish/dataclasses/impl/generation/globals.py +1 -0
  36. omlish/dataclasses/impl/generation/ops.py +1 -0
  37. omlish/dataclasses/impl/generation/plans.py +2 -17
  38. omlish/dataclasses/impl/generation/processor.py +106 -25
  39. omlish/dataclasses/impl/processing/base.py +8 -0
  40. omlish/dataclasses/impl/processing/driving.py +19 -7
  41. omlish/dataclasses/specs.py +1 -0
  42. omlish/dataclasses/tools/modifiers.py +5 -0
  43. omlish/diag/_pycharm/runhack.py +1 -1
  44. omlish/diag/cmds/__init__.py +0 -0
  45. omlish/diag/{lslocks.py → cmds/lslocks.py} +6 -6
  46. omlish/diag/{lsof.py → cmds/lsof.py} +6 -6
  47. omlish/diag/{ps.py → cmds/ps.py} +6 -6
  48. omlish/diag/pycharm.py +16 -2
  49. omlish/diag/pydevd.py +58 -40
  50. omlish/diag/replserver/console.py +1 -1
  51. omlish/dispatch/__init__.py +18 -12
  52. omlish/dispatch/methods.py +50 -140
  53. omlish/dom/rendering.py +1 -1
  54. omlish/formats/dotenv.py +1 -1
  55. omlish/formats/json/stream/__init__.py +13 -0
  56. omlish/funcs/guard.py +225 -0
  57. omlish/graphs/dot/rendering.py +1 -1
  58. omlish/http/all.py +44 -4
  59. omlish/http/clients/asyncs.py +33 -27
  60. omlish/http/clients/base.py +17 -1
  61. omlish/http/clients/coro/__init__.py +0 -0
  62. omlish/http/clients/coro/sync.py +171 -0
  63. omlish/http/clients/default.py +208 -29
  64. omlish/http/clients/executor.py +56 -0
  65. omlish/http/clients/httpx.py +72 -11
  66. omlish/http/clients/middleware.py +181 -0
  67. omlish/http/clients/sync.py +33 -27
  68. omlish/http/clients/syncasync.py +49 -0
  69. omlish/http/clients/urllib.py +6 -3
  70. omlish/http/coro/client/connection.py +15 -6
  71. omlish/http/coro/io.py +2 -0
  72. omlish/http/flasky/__init__.py +40 -0
  73. omlish/http/flasky/_compat.py +2 -0
  74. omlish/http/flasky/api.py +82 -0
  75. omlish/http/flasky/app.py +203 -0
  76. omlish/http/flasky/cvs.py +59 -0
  77. omlish/http/flasky/requests.py +20 -0
  78. omlish/http/flasky/responses.py +23 -0
  79. omlish/http/flasky/routes.py +23 -0
  80. omlish/http/flasky/types.py +15 -0
  81. omlish/http/urls.py +67 -0
  82. omlish/inject/__init__.py +57 -29
  83. omlish/inject/_dataclasses.py +5148 -0
  84. omlish/inject/binder.py +11 -52
  85. omlish/inject/eagers.py +2 -0
  86. omlish/inject/elements.py +27 -0
  87. omlish/inject/helpers/__init__.py +0 -0
  88. omlish/inject/{utils.py → helpers/constfn.py} +3 -3
  89. omlish/inject/{tags.py → helpers/id.py} +2 -2
  90. omlish/inject/helpers/late.py +76 -0
  91. omlish/inject/{managed.py → helpers/managed.py} +10 -10
  92. omlish/inject/helpers/multis.py +143 -0
  93. omlish/inject/helpers/wrappers.py +54 -0
  94. omlish/inject/impl/elements.py +54 -21
  95. omlish/inject/impl/injector.py +29 -25
  96. omlish/inject/impl/inspect.py +10 -1
  97. omlish/inject/impl/maysync.py +3 -4
  98. omlish/inject/impl/multis.py +3 -0
  99. omlish/inject/impl/sync.py +3 -4
  100. omlish/inject/injector.py +31 -2
  101. omlish/inject/inspect.py +35 -0
  102. omlish/inject/maysync.py +2 -4
  103. omlish/inject/multis.py +8 -0
  104. omlish/inject/overrides.py +3 -3
  105. omlish/inject/privates.py +6 -0
  106. omlish/inject/providers.py +3 -2
  107. omlish/inject/sync.py +5 -4
  108. omlish/io/buffers.py +118 -0
  109. omlish/io/readers.py +29 -0
  110. omlish/iterators/transforms.py +2 -2
  111. omlish/lang/__init__.py +180 -97
  112. omlish/lang/_asyncs.cc +186 -0
  113. omlish/lang/asyncs.py +17 -0
  114. omlish/lang/casing.py +11 -0
  115. omlish/lang/contextmanagers.py +28 -4
  116. omlish/lang/functions.py +31 -22
  117. omlish/lang/imports/_capture.cc +11 -9
  118. omlish/lang/imports/capture.py +363 -170
  119. omlish/lang/imports/proxy.py +455 -152
  120. omlish/lang/lazyglobals.py +22 -9
  121. omlish/lang/params.py +17 -0
  122. omlish/lang/recursion.py +0 -1
  123. omlish/lang/sequences.py +124 -0
  124. omlish/lifecycles/README.md +30 -0
  125. omlish/lifecycles/__init__.py +87 -13
  126. omlish/lifecycles/_dataclasses.py +1388 -0
  127. omlish/lifecycles/base.py +178 -64
  128. omlish/lifecycles/contextmanagers.py +113 -4
  129. omlish/lifecycles/controller.py +150 -87
  130. omlish/lifecycles/injection.py +143 -0
  131. omlish/lifecycles/listeners.py +56 -0
  132. omlish/lifecycles/managed.py +142 -0
  133. omlish/lifecycles/manager.py +218 -93
  134. omlish/lifecycles/states.py +2 -0
  135. omlish/lifecycles/transitions.py +3 -0
  136. omlish/lifecycles/unwrap.py +57 -0
  137. omlish/lite/abstract.py +54 -24
  138. omlish/lite/asyncs.py +2 -2
  139. omlish/lite/attrops.py +2 -0
  140. omlish/lite/contextmanagers.py +4 -4
  141. omlish/lite/dataclasses.py +44 -0
  142. omlish/lite/maybes.py +8 -0
  143. omlish/lite/maysync.py +1 -5
  144. omlish/lite/pycharm.py +1 -1
  145. omlish/lite/typing.py +24 -0
  146. omlish/logs/_amalg.py +1 -1
  147. omlish/logs/all.py +25 -11
  148. omlish/logs/asyncs.py +73 -0
  149. omlish/logs/base.py +101 -12
  150. omlish/logs/contexts.py +4 -1
  151. omlish/logs/lists.py +125 -0
  152. omlish/logs/modules.py +19 -1
  153. omlish/logs/std/loggers.py +6 -1
  154. omlish/logs/std/noisy.py +11 -9
  155. omlish/logs/{standard.py → std/standard.py} +3 -4
  156. omlish/logs/utils.py +17 -2
  157. omlish/manifests/loading.py +2 -1
  158. omlish/marshal/__init__.py +33 -13
  159. omlish/marshal/_dataclasses.py +2774 -0
  160. omlish/marshal/base/configs.py +12 -0
  161. omlish/marshal/base/contexts.py +36 -21
  162. omlish/marshal/base/funcs.py +8 -11
  163. omlish/marshal/base/options.py +8 -0
  164. omlish/marshal/base/registries.py +146 -44
  165. omlish/marshal/base/types.py +40 -16
  166. omlish/marshal/composite/iterables.py +33 -20
  167. omlish/marshal/composite/literals.py +20 -18
  168. omlish/marshal/composite/mappings.py +36 -23
  169. omlish/marshal/composite/maybes.py +29 -19
  170. omlish/marshal/composite/newtypes.py +16 -16
  171. omlish/marshal/composite/optionals.py +14 -14
  172. omlish/marshal/composite/special.py +15 -15
  173. omlish/marshal/composite/unions/__init__.py +0 -0
  174. omlish/marshal/composite/unions/literals.py +93 -0
  175. omlish/marshal/composite/unions/primitives.py +103 -0
  176. omlish/marshal/factories/invalidate.py +18 -68
  177. omlish/marshal/factories/method.py +26 -0
  178. omlish/marshal/factories/moduleimport/factories.py +22 -65
  179. omlish/marshal/factories/multi.py +13 -25
  180. omlish/marshal/factories/recursive.py +42 -56
  181. omlish/marshal/factories/typecache.py +29 -74
  182. omlish/marshal/factories/typemap.py +42 -43
  183. omlish/marshal/objects/dataclasses.py +129 -106
  184. omlish/marshal/objects/marshal.py +18 -14
  185. omlish/marshal/objects/namedtuples.py +48 -42
  186. omlish/marshal/objects/unmarshal.py +19 -15
  187. omlish/marshal/polymorphism/marshal.py +9 -11
  188. omlish/marshal/polymorphism/metadata.py +16 -5
  189. omlish/marshal/polymorphism/standard.py +13 -1
  190. omlish/marshal/polymorphism/unions.py +15 -105
  191. omlish/marshal/polymorphism/unmarshal.py +9 -10
  192. omlish/marshal/singular/enums.py +14 -18
  193. omlish/marshal/standard.py +10 -6
  194. omlish/marshal/trivial/any.py +1 -1
  195. omlish/marshal/trivial/forbidden.py +21 -26
  196. omlish/metadata.py +23 -1
  197. omlish/os/forkhooks.py +4 -0
  198. omlish/os/pidfiles/pinning.py +2 -2
  199. omlish/reflect/__init__.py +43 -26
  200. omlish/reflect/ops.py +10 -1
  201. omlish/reflect/types.py +1 -0
  202. omlish/secrets/marshal.py +1 -1
  203. omlish/specs/jmespath/__init__.py +12 -3
  204. omlish/specs/jmespath/_dataclasses.py +2893 -0
  205. omlish/specs/jmespath/ast.py +1 -1
  206. omlish/specs/jsonrpc/__init__.py +13 -0
  207. omlish/specs/jsonrpc/_marshal.py +32 -23
  208. omlish/specs/jsonrpc/conns.py +10 -7
  209. omlish/specs/jsonschema/_marshal.py +1 -1
  210. omlish/specs/jsonschema/keywords/__init__.py +7 -0
  211. omlish/specs/jsonschema/keywords/_dataclasses.py +1644 -0
  212. omlish/specs/openapi/_marshal.py +31 -22
  213. omlish/sql/__init__.py +24 -5
  214. omlish/sql/{tabledefs/alchemy.py → alchemy/tabledefs.py} +2 -2
  215. omlish/sql/api/dbapi.py +1 -1
  216. omlish/sql/dbapi/__init__.py +15 -0
  217. omlish/sql/{dbapi.py → dbapi/drivers.py} +2 -2
  218. omlish/sql/queries/__init__.py +3 -0
  219. omlish/sql/queries/_marshal.py +2 -2
  220. omlish/sql/queries/rendering.py +1 -1
  221. omlish/sql/tabledefs/_marshal.py +1 -1
  222. omlish/subprocesses/base.py +4 -0
  223. omlish/subprocesses/editor.py +1 -1
  224. omlish/sync.py +155 -21
  225. omlish/term/alt.py +60 -0
  226. omlish/term/confirm.py +8 -8
  227. omlish/term/pager.py +235 -0
  228. omlish/term/terminfo.py +935 -0
  229. omlish/term/termstate.py +67 -0
  230. omlish/term/vt100/terminal.py +0 -3
  231. omlish/testing/pytest/plugins/asyncs/fixtures.py +4 -1
  232. omlish/testing/pytest/plugins/asyncs/plugin.py +2 -0
  233. omlish/testing/pytest/plugins/skips.py +2 -1
  234. omlish/testing/unittest/main.py +3 -3
  235. omlish/text/docwrap/__init__.py +3 -0
  236. omlish/text/docwrap/__main__.py +11 -0
  237. omlish/text/docwrap/api.py +83 -0
  238. omlish/text/docwrap/cli.py +91 -0
  239. omlish/text/docwrap/groups.py +84 -0
  240. omlish/text/docwrap/lists.py +167 -0
  241. omlish/text/docwrap/parts.py +146 -0
  242. omlish/text/docwrap/reflowing.py +106 -0
  243. omlish/text/docwrap/rendering.py +151 -0
  244. omlish/text/docwrap/utils.py +11 -0
  245. omlish/text/docwrap/wrapping.py +59 -0
  246. omlish/text/filecache.py +2 -2
  247. omlish/text/lorem.py +6 -0
  248. omlish/text/parts.py +2 -2
  249. omlish/text/textwrap.py +51 -0
  250. omlish/typedvalues/marshal.py +85 -59
  251. omlish/typedvalues/values.py +2 -1
  252. {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev493.dist-info}/METADATA +36 -32
  253. {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev493.dist-info}/RECORD +260 -199
  254. omlish/dataclasses/impl/generation/mangling.py +0 -18
  255. omlish/funcs/match.py +0 -227
  256. omlish/lifecycles/abstract.py +0 -86
  257. omlish/marshal/factories/match.py +0 -34
  258. omlish/marshal/factories/simple.py +0 -28
  259. /omlish/inject/{impl → helpers}/proxy.py +0 -0
  260. /omlish/inject/impl/{providers2.py → providersmap.py} +0 -0
  261. /omlish/sql/{abc.py → dbapi/abc.py} +0 -0
  262. {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev493.dist-info}/WHEEL +0 -0
  263. {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev493.dist-info}/entry_points.txt +0 -0
  264. {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev493.dist-info}/licenses/LICENSE +0 -0
  265. {omlish-0.0.0.dev447.dist-info → omlish-0.0.0.dev493.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
- NoBool,
102
+ Final,
103
+
104
+ SealedError,
105
+ Sealed,
106
+ PackageSealed,
107
+
98
108
  NotInstantiable,
99
109
  NotPicklable,
100
- PackageSealed,
110
+
111
+ NoBool,
112
+ no_bool,
113
+
101
114
  SENSITIVE_ATTR,
102
- Sealed,
103
- SealedError,
104
115
  Sensitive,
105
- no_bool,
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
- Infinity,
154
+ cmp,
155
+
138
156
  InfinityType,
139
- NegativeInfinity,
157
+ Infinity,
140
158
  NegativeInfinityType,
141
- cmp,
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
- unwrap_callable,
205
- unwrap_callable_with_partials,
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
- VoidError,
250
+ is_lambda,
251
+
222
252
  call_with,
223
- coalesce,
224
- cond_kw,
225
- constant,
253
+ opt_call,
254
+ opt_fn,
255
+ recurse,
256
+
257
+ raise_,
258
+ raising,
259
+ try_,
226
260
  finally_,
261
+
227
262
  identity,
228
- is_lambda,
263
+ constant,
264
+ nullary_constant,
265
+
229
266
  is_none,
230
267
  is_not_none,
231
268
  isinstance_of,
232
269
  issubclass_of,
233
- maybe_call,
234
- new_function,
235
- new_function_kwargs,
236
- nullary_constant,
270
+ strict_eq,
271
+
272
+ VoidError,
273
+ Void,
274
+ void,
275
+
276
+ periodically,
277
+
278
+ opt_getattr,
279
+ coalesce,
237
280
  opt_coalesce,
238
- opt_fn,
281
+
282
+ cond_kw,
239
283
  opt_kw,
240
- periodically,
241
- raise_,
242
- raising,
243
- recurse,
244
- strict_eq,
245
284
  truthy_kw,
246
- try_,
247
- void,
285
+
286
+ new_function,
287
+ new_function_kwargs,
288
+ copy_function,
248
289
  )
249
290
 
250
291
  from .generators import ( # noqa
251
- GeneratorLike,
252
- GeneratorMappedIterator,
292
+ nextgen,
253
293
  autostart,
254
- capture_coroutine,
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
- peek,
353
+
354
+ flatten,
355
+ flatmap,
356
+
357
+ asrange,
308
358
  prodrange,
309
- readiter,
310
- renumerate,
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
- deep_subclasses,
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
- Value,
350
- acapture,
401
+
351
402
  capture,
352
- error,
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
- Param,
433
+
434
+ ValParam,
435
+ PosOnlyParam,
436
+ KwOnlyParam,
437
+
370
438
  ParamSeparator,
439
+
371
440
  ParamSpec,
372
- PosOnlyParam,
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
- replace_many,
413
- rfind_any,
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,
@@ -540,6 +621,8 @@ with _auto_proxy_init(globals(), update_exports=True):
540
621
  Func2,
541
622
  Func3,
542
623
 
624
+ CachedFunc0,
625
+
543
626
  typing_annotations_attr,
544
627
  )
545
628
 
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