omlish 0.0.0.dev133__py3-none-any.whl → 0.0.0.dev177__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.
Files changed (210) hide show
  1. omlish/.manifests.json +265 -7
  2. omlish/__about__.py +5 -3
  3. omlish/antlr/_runtime/__init__.py +0 -22
  4. omlish/antlr/_runtime/_all.py +24 -0
  5. omlish/antlr/_runtime/atn/ParserATNSimulator.py +1 -1
  6. omlish/antlr/_runtime/dfa/DFASerializer.py +1 -1
  7. omlish/antlr/_runtime/error/DiagnosticErrorListener.py +2 -1
  8. omlish/antlr/_runtime/xpath/XPath.py +7 -1
  9. omlish/antlr/_runtime/xpath/XPathLexer.py +1 -1
  10. omlish/antlr/delimit.py +106 -0
  11. omlish/antlr/dot.py +31 -0
  12. omlish/antlr/errors.py +11 -0
  13. omlish/antlr/input.py +96 -0
  14. omlish/antlr/parsing.py +19 -0
  15. omlish/antlr/runtime.py +102 -0
  16. omlish/antlr/utils.py +38 -0
  17. omlish/argparse/all.py +45 -0
  18. omlish/{argparse.py → argparse/cli.py} +112 -107
  19. omlish/asyncs/__init__.py +0 -35
  20. omlish/asyncs/all.py +35 -0
  21. omlish/asyncs/asyncio/all.py +7 -0
  22. omlish/asyncs/asyncio/channels.py +40 -0
  23. omlish/asyncs/asyncio/streams.py +45 -0
  24. omlish/asyncs/asyncio/subprocesses.py +238 -0
  25. omlish/asyncs/asyncio/timeouts.py +16 -0
  26. omlish/asyncs/bluelet/LICENSE +6 -0
  27. omlish/asyncs/bluelet/all.py +67 -0
  28. omlish/asyncs/bluelet/api.py +23 -0
  29. omlish/asyncs/bluelet/core.py +178 -0
  30. omlish/asyncs/bluelet/events.py +78 -0
  31. omlish/asyncs/bluelet/files.py +80 -0
  32. omlish/asyncs/bluelet/runner.py +416 -0
  33. omlish/asyncs/bluelet/sockets.py +214 -0
  34. omlish/bootstrap/sys.py +3 -3
  35. omlish/cached.py +2 -2
  36. omlish/check.py +49 -460
  37. omlish/codecs/__init__.py +72 -0
  38. omlish/codecs/base.py +106 -0
  39. omlish/codecs/bytes.py +119 -0
  40. omlish/codecs/chain.py +23 -0
  41. omlish/codecs/funcs.py +39 -0
  42. omlish/codecs/registry.py +139 -0
  43. omlish/codecs/standard.py +4 -0
  44. omlish/codecs/text.py +217 -0
  45. omlish/collections/cache/impl.py +50 -57
  46. omlish/collections/coerce.py +1 -0
  47. omlish/collections/mappings.py +1 -1
  48. omlish/configs/flattening.py +1 -1
  49. omlish/defs.py +1 -1
  50. omlish/diag/_pycharm/runhack.py +8 -2
  51. omlish/diag/procfs.py +8 -8
  52. omlish/docker/__init__.py +0 -36
  53. omlish/docker/all.py +31 -0
  54. omlish/docker/consts.py +4 -0
  55. omlish/{lite/docker.py → docker/detect.py} +18 -0
  56. omlish/docker/{helpers.py → timebomb.py} +0 -21
  57. omlish/formats/cbor.py +31 -0
  58. omlish/formats/cloudpickle.py +31 -0
  59. omlish/formats/codecs.py +93 -0
  60. omlish/formats/json/codecs.py +29 -0
  61. omlish/formats/json/delimted.py +4 -0
  62. omlish/formats/json/stream/errors.py +2 -0
  63. omlish/formats/json/stream/lex.py +12 -6
  64. omlish/formats/json/stream/parse.py +38 -22
  65. omlish/formats/json5.py +31 -0
  66. omlish/formats/pickle.py +31 -0
  67. omlish/formats/repr.py +25 -0
  68. omlish/formats/toml.py +17 -0
  69. omlish/formats/yaml.py +25 -0
  70. omlish/funcs/__init__.py +0 -0
  71. omlish/{genmachine.py → funcs/genmachine.py} +5 -4
  72. omlish/{matchfns.py → funcs/match.py} +1 -1
  73. omlish/funcs/pairs.py +215 -0
  74. omlish/http/__init__.py +0 -48
  75. omlish/http/all.py +48 -0
  76. omlish/http/coro/__init__.py +0 -0
  77. omlish/{lite/fdio/corohttp.py → http/coro/fdio.py} +21 -19
  78. omlish/{lite/http/coroserver.py → http/coro/server.py} +20 -21
  79. omlish/{lite/http → http}/handlers.py +3 -2
  80. omlish/{lite/http → http}/parsing.py +1 -0
  81. omlish/http/sessions.py +1 -1
  82. omlish/{lite/http → http}/versions.py +1 -0
  83. omlish/inject/managed.py +2 -2
  84. omlish/io/__init__.py +0 -3
  85. omlish/{lite/io.py → io/buffers.py} +8 -9
  86. omlish/io/compress/__init__.py +9 -0
  87. omlish/io/compress/abc.py +104 -0
  88. omlish/io/compress/adapters.py +148 -0
  89. omlish/io/compress/base.py +24 -0
  90. omlish/io/compress/brotli.py +47 -0
  91. omlish/io/compress/bz2.py +61 -0
  92. omlish/io/compress/codecs.py +78 -0
  93. omlish/io/compress/gzip.py +350 -0
  94. omlish/io/compress/lz4.py +91 -0
  95. omlish/io/compress/lzma.py +81 -0
  96. omlish/io/compress/snappy.py +34 -0
  97. omlish/io/compress/zlib.py +74 -0
  98. omlish/io/compress/zstd.py +44 -0
  99. omlish/io/fdio/__init__.py +1 -0
  100. omlish/{lite → io}/fdio/handlers.py +5 -5
  101. omlish/{lite → io}/fdio/kqueue.py +8 -8
  102. omlish/{lite → io}/fdio/manager.py +7 -7
  103. omlish/{lite → io}/fdio/pollers.py +13 -13
  104. omlish/io/generators/__init__.py +56 -0
  105. omlish/io/generators/consts.py +1 -0
  106. omlish/io/generators/direct.py +13 -0
  107. omlish/io/generators/readers.py +189 -0
  108. omlish/io/generators/stepped.py +191 -0
  109. omlish/io/pyio.py +5 -2
  110. omlish/iterators/__init__.py +24 -0
  111. omlish/iterators/iterators.py +132 -0
  112. omlish/iterators/recipes.py +18 -0
  113. omlish/iterators/tools.py +96 -0
  114. omlish/iterators/unique.py +67 -0
  115. omlish/lang/__init__.py +13 -1
  116. omlish/lang/functions.py +11 -2
  117. omlish/lang/generators.py +243 -0
  118. omlish/lang/iterables.py +46 -49
  119. omlish/lang/maybes.py +4 -4
  120. omlish/lite/cached.py +39 -6
  121. omlish/lite/check.py +438 -75
  122. omlish/lite/contextmanagers.py +17 -4
  123. omlish/lite/dataclasses.py +42 -0
  124. omlish/lite/inject.py +28 -45
  125. omlish/lite/logs.py +0 -270
  126. omlish/lite/marshal.py +309 -144
  127. omlish/lite/pycharm.py +47 -0
  128. omlish/lite/reflect.py +33 -0
  129. omlish/lite/resources.py +8 -0
  130. omlish/lite/runtime.py +4 -4
  131. omlish/lite/shlex.py +12 -0
  132. omlish/lite/socketserver.py +2 -2
  133. omlish/lite/strings.py +31 -0
  134. omlish/logs/__init__.py +0 -32
  135. omlish/logs/{_abc.py → abc.py} +0 -1
  136. omlish/logs/all.py +37 -0
  137. omlish/logs/{formatters.py → color.py} +1 -2
  138. omlish/logs/configs.py +7 -38
  139. omlish/logs/filters.py +10 -0
  140. omlish/logs/handlers.py +4 -1
  141. omlish/logs/json.py +56 -0
  142. omlish/logs/proxy.py +99 -0
  143. omlish/logs/standard.py +128 -0
  144. omlish/logs/utils.py +2 -2
  145. omlish/manifests/__init__.py +2 -0
  146. omlish/manifests/load.py +209 -0
  147. omlish/manifests/types.py +17 -0
  148. omlish/marshal/base.py +1 -1
  149. omlish/marshal/factories.py +1 -1
  150. omlish/marshal/forbidden.py +1 -1
  151. omlish/marshal/iterables.py +1 -1
  152. omlish/marshal/literals.py +50 -0
  153. omlish/marshal/mappings.py +1 -1
  154. omlish/marshal/maybes.py +1 -1
  155. omlish/marshal/standard.py +5 -1
  156. omlish/marshal/unions.py +1 -1
  157. omlish/os/__init__.py +0 -0
  158. omlish/os/atomics.py +205 -0
  159. omlish/os/deathsig.py +23 -0
  160. omlish/{os.py → os/files.py} +0 -9
  161. omlish/{lite → os}/journald.py +2 -1
  162. omlish/os/linux.py +484 -0
  163. omlish/os/paths.py +36 -0
  164. omlish/{lite → os}/pidfile.py +1 -0
  165. omlish/os/sizes.py +9 -0
  166. omlish/reflect/__init__.py +3 -0
  167. omlish/reflect/subst.py +2 -1
  168. omlish/reflect/types.py +126 -44
  169. omlish/secrets/pwhash.py +1 -1
  170. omlish/secrets/subprocesses.py +3 -1
  171. omlish/specs/jsonrpc/marshal.py +1 -1
  172. omlish/specs/openapi/marshal.py +1 -1
  173. omlish/sql/alchemy/asyncs.py +1 -1
  174. omlish/sql/queries/__init__.py +9 -1
  175. omlish/sql/queries/building.py +3 -0
  176. omlish/sql/queries/exprs.py +10 -27
  177. omlish/sql/queries/idents.py +48 -10
  178. omlish/sql/queries/names.py +80 -13
  179. omlish/sql/queries/params.py +64 -0
  180. omlish/sql/queries/rendering.py +1 -1
  181. omlish/subprocesses.py +340 -0
  182. omlish/term.py +29 -14
  183. omlish/testing/pytest/marks.py +2 -2
  184. omlish/testing/pytest/plugins/asyncs.py +6 -1
  185. omlish/testing/pytest/plugins/logging.py +1 -1
  186. omlish/testing/pytest/plugins/switches.py +1 -1
  187. {omlish-0.0.0.dev133.dist-info → omlish-0.0.0.dev177.dist-info}/METADATA +7 -5
  188. {omlish-0.0.0.dev133.dist-info → omlish-0.0.0.dev177.dist-info}/RECORD +200 -117
  189. omlish/fnpairs.py +0 -496
  190. omlish/formats/json/cli/__main__.py +0 -11
  191. omlish/formats/json/cli/cli.py +0 -298
  192. omlish/formats/json/cli/formats.py +0 -71
  193. omlish/formats/json/cli/io.py +0 -74
  194. omlish/formats/json/cli/parsing.py +0 -82
  195. omlish/formats/json/cli/processing.py +0 -48
  196. omlish/formats/json/cli/rendering.py +0 -92
  197. omlish/iterators.py +0 -300
  198. omlish/lite/subprocesses.py +0 -130
  199. /omlish/{formats/json/cli → argparse}/__init__.py +0 -0
  200. /omlish/{lite/fdio → asyncs/asyncio}/__init__.py +0 -0
  201. /omlish/asyncs/{asyncio.py → asyncio/asyncio.py} +0 -0
  202. /omlish/{lite/http → asyncs/bluelet}/__init__.py +0 -0
  203. /omlish/collections/{_abc.py → abc.py} +0 -0
  204. /omlish/{fnpipes.py → funcs/pipes.py} +0 -0
  205. /omlish/io/{_abc.py → abc.py} +0 -0
  206. /omlish/sql/{_abc.py → abc.py} +0 -0
  207. {omlish-0.0.0.dev133.dist-info → omlish-0.0.0.dev177.dist-info}/LICENSE +0 -0
  208. {omlish-0.0.0.dev133.dist-info → omlish-0.0.0.dev177.dist-info}/WHEEL +0 -0
  209. {omlish-0.0.0.dev133.dist-info → omlish-0.0.0.dev177.dist-info}/entry_points.txt +0 -0
  210. {omlish-0.0.0.dev133.dist-info → omlish-0.0.0.dev177.dist-info}/top_level.txt +0 -0
omlish/bootstrap/sys.py CHANGED
@@ -21,15 +21,15 @@ from .base import SimpleBootstrap
21
21
 
22
22
  if ta.TYPE_CHECKING:
23
23
  from .. import libc
24
- from .. import logs
25
24
  from ..formats import dotenv
26
- from ..lite import pidfile
25
+ from ..logs import all as logs
26
+ from ..os import pidfile
27
27
 
28
28
  else:
29
29
  libc = lang.proxy_import('..libc', __package__)
30
30
  logs = lang.proxy_import('..logs', __package__)
31
31
  dotenv = lang.proxy_import('..formats.dotenv', __package__)
32
- pidfile = lang.proxy_import('..lite.pidfile', __package__)
32
+ pidfile = lang.proxy_import('..os.pidfile', __package__)
33
33
 
34
34
 
35
35
  ##
omlish/cached.py CHANGED
@@ -10,9 +10,9 @@ builtins and thus not distinguish it from a normal property.
10
10
 
11
11
  """
12
12
  from .lang.cached import _CachedProperty # noqa
13
- from .lang.cached import cached_function
13
+ from .lang.cached import cached_function as _cached_function
14
14
 
15
- function = cached_function
15
+ function = _cached_function
16
16
 
17
17
  property = property # noqa
18
18
 
omlish/check.py CHANGED
@@ -1,18 +1,13 @@
1
- """
2
- TODO:
3
- - def maybe(v: lang.Maybe[T])
4
- """
5
- import collections
6
- import threading
7
1
  import typing as ta
8
2
 
3
+ from .lite.check import CheckArgsRenderer as ArgsRenderer # noqa
4
+ from .lite.check import CheckExceptionFactory as ExceptionFactory # noqa
5
+ from .lite.check import CheckLateConfigureFn as LateConfigureFn # noqa
6
+ from .lite.check import CheckMessage as Message # noqa
7
+ from .lite.check import CheckOnRaiseFn as OnRaiseFn # noqa
8
+ from .lite.check import Checks
9
+ from .lite.check import check
9
10
 
10
- T = ta.TypeVar('T')
11
- SizedT = ta.TypeVar('SizedT', bound=ta.Sized)
12
-
13
- Message: ta.TypeAlias = str | ta.Callable[..., str | None] | None
14
-
15
- _NONE_TYPE = type(None)
16
11
 
17
12
  _isinstance = isinstance
18
13
  _issubclass = issubclass
@@ -22,43 +17,21 @@ _callable = callable
22
17
  ##
23
18
 
24
19
 
25
- _CONFIG_LOCK = threading.RLock()
26
-
27
-
28
- OnRaiseFn: ta.TypeAlias = ta.Callable[[Exception], None]
29
- _ON_RAISE: ta.Sequence[OnRaiseFn] = []
30
-
31
-
32
- def register_on_raise(fn: OnRaiseFn) -> None:
33
- global _ON_RAISE
34
- with _CONFIG_LOCK:
35
- _ON_RAISE = [*_ON_RAISE, fn]
36
-
37
-
38
- def unregister_on_raise(fn: OnRaiseFn) -> None:
39
- global _ON_RAISE
40
- with _CONFIG_LOCK:
41
- _ON_RAISE = [e for e in _ON_RAISE if e != fn]
20
+ register_on_raise = check.register_on_raise
21
+ unregister_on_raise = check.unregister_on_raise
42
22
 
43
23
 
44
- #
45
-
46
-
47
- _ARGS_RENDERER: ta.Callable[..., str | None] | None = None
48
-
24
+ ##
49
25
 
50
- def _try_enable_args_rendering() -> bool:
51
- global _ARGS_RENDERER
52
- if _ARGS_RENDERER is not None:
53
- return True
54
26
 
27
+ def _try_get_args_rendering() -> ArgsRenderer | None:
55
28
  try:
56
29
  from .diag.asts import ArgsRenderer
57
30
 
58
31
  ArgsRenderer.smoketest()
59
32
 
60
33
  except Exception: # noqa
61
- return False
34
+ return None
62
35
 
63
36
  def _real_render_args(fmt: str, *args: ta.Any) -> str | None:
64
37
  ra = ArgsRenderer(back=3).render_args(*args)
@@ -67,443 +40,59 @@ def _try_enable_args_rendering() -> bool:
67
40
 
68
41
  return fmt % tuple(str(a) for a in ra)
69
42
 
70
- _ARGS_RENDERER = _real_render_args
71
- return True
72
-
73
-
74
- _TRIED_ENABLED_ARGS_RENDERING: bool | None = None
75
-
76
-
77
- def try_enable_args_rendering() -> bool:
78
- global _TRIED_ENABLED_ARGS_RENDERING
79
- if _TRIED_ENABLED_ARGS_RENDERING is not None:
80
- return _TRIED_ENABLED_ARGS_RENDERING
81
-
82
- with _CONFIG_LOCK:
83
- if _TRIED_ENABLED_ARGS_RENDERING is None:
84
- _TRIED_ENABLED_ARGS_RENDERING = _try_enable_args_rendering()
85
-
86
- return _TRIED_ENABLED_ARGS_RENDERING
87
-
88
-
89
- ##
90
-
91
-
92
- def _default_exception_factory(exc_cls: type[Exception], *args, **kwargs) -> Exception:
93
- return exc_cls(*args, **kwargs) # noqa
94
-
95
-
96
- _EXCEPTION_FACTORY = _default_exception_factory
97
-
98
-
99
- class _ArgsKwargs:
100
- def __init__(self, *args, **kwargs):
101
- self.args = args
102
- self.kwargs = kwargs
103
-
104
-
105
- def _raise(
106
- exception_type: type[Exception],
107
- default_message: str,
108
- message: Message,
109
- ak: _ArgsKwargs = _ArgsKwargs(),
110
- *,
111
- render_fmt: str | None = None,
112
- ) -> ta.NoReturn:
113
- exc_args = ()
114
- if _callable(message):
115
- message = ta.cast(ta.Callable, message)(*ak.args, **ak.kwargs)
116
- if _isinstance(message, tuple):
117
- message, *exc_args = message # type: ignore
118
-
119
- if message is None:
120
- message = default_message
121
-
122
- try_enable_args_rendering()
123
-
124
- if render_fmt is not None and _ARGS_RENDERER is not None:
125
- rendered_args = _ARGS_RENDERER(render_fmt, *ak.args)
126
- if rendered_args is not None:
127
- message = f'{message} : {rendered_args}'
128
-
129
- exc = _EXCEPTION_FACTORY(
130
- exception_type,
131
- message,
132
- *exc_args,
133
- *ak.args,
134
- **ak.kwargs,
135
- )
136
-
137
- for fn in _ON_RAISE:
138
- fn(exc)
139
-
140
- raise exc
141
-
142
-
143
- ##
144
-
145
-
146
- def _unpack_isinstance_spec(spec: ta.Any) -> tuple:
147
- if not _isinstance(spec, tuple):
148
- spec = (spec,)
149
- if None in spec:
150
- spec = tuple(filter(None, spec)) + (_NONE_TYPE,) # noqa
151
- if ta.Any in spec:
152
- spec = (object,)
153
- return spec
154
-
155
-
156
- def isinstance(v: ta.Any, spec: type[T] | tuple, msg: Message = None) -> T: # noqa
157
- if not _isinstance(v, _unpack_isinstance_spec(spec)):
158
- _raise(
159
- TypeError,
160
- 'Must be instance',
161
- msg,
162
- _ArgsKwargs(v, spec),
163
- render_fmt='not isinstance(%s, %s)',
164
- )
165
-
166
- return v
167
-
168
-
169
- def of_isinstance(spec: type[T] | tuple, msg: Message = None) -> ta.Callable[[ta.Any], T]:
170
- def inner(v):
171
- return isinstance(v, _unpack_isinstance_spec(spec), msg)
172
-
173
- return inner
174
-
175
-
176
- def cast(v: ta.Any, cls: type[T], msg: Message = None) -> T: # noqa
177
- if not _isinstance(v, cls):
178
- _raise(
179
- TypeError,
180
- 'Must be instance',
181
- msg,
182
- _ArgsKwargs(v, cls),
183
- )
184
-
185
- return v
186
-
187
-
188
- def of_cast(cls: type[T], msg: Message = None) -> ta.Callable[[T], T]:
189
- def inner(v):
190
- return isinstance(v, cls, msg)
191
-
192
- return inner
193
-
194
-
195
- def not_isinstance(v: T, spec: ta.Any, msg: Message = None) -> T: # noqa
196
- if _isinstance(v, _unpack_isinstance_spec(spec)):
197
- _raise(
198
- TypeError,
199
- 'Must not be instance',
200
- msg,
201
- _ArgsKwargs(v, spec),
202
- render_fmt='isinstance(%s, %s)',
203
- )
204
-
205
- return v
206
-
43
+ return _real_render_args
207
44
 
208
- def of_not_isinstance(spec: ta.Any, msg: Message = None) -> ta.Callable[[T], T]:
209
- def inner(v):
210
- return not_isinstance(v, _unpack_isinstance_spec(spec), msg)
211
45
 
212
- return inner
46
+ def _try_enable_args_rendering(c: Checks) -> None:
47
+ if (rf := _try_get_args_rendering()) is not None:
48
+ c.set_args_renderer(rf)
213
49
 
214
50
 
215
- ##
216
-
217
-
218
- def issubclass(v: type[T], spec: ta.Any, msg: Message = None) -> type[T]: # noqa
219
- if not _issubclass(v, spec):
220
- _raise(
221
- TypeError,
222
- 'Must be subclass',
223
- msg,
224
- _ArgsKwargs(v, spec),
225
- render_fmt='not issubclass(%s, %s)',
226
- )
227
-
228
- return v
229
-
230
-
231
- def not_issubclass(v: type[T], spec: ta.Any, msg: Message = None) -> type[T]: # noqa
232
- if _issubclass(v, spec):
233
- _raise(
234
- TypeError,
235
- 'Must not be subclass',
236
- msg,
237
- _ArgsKwargs(v, spec),
238
- render_fmt='issubclass(%s, %s)',
239
- )
240
-
241
- return v
242
-
243
-
244
- ##
245
-
246
-
247
- def in_(v: T, c: ta.Container[T], msg: Message = None) -> T:
248
- if v not in c:
249
- _raise(
250
- ValueError,
251
- 'Must be in',
252
- msg,
253
- _ArgsKwargs(v, c),
254
- render_fmt='%s not in %s',
255
- )
256
-
257
- return v
258
-
259
-
260
- def not_in(v: T, c: ta.Container[T], msg: Message = None) -> T:
261
- if v in c:
262
- _raise(
263
- ValueError,
264
- 'Must not be in',
265
- msg,
266
- _ArgsKwargs(v, c),
267
- render_fmt='%s in %s',
268
- )
269
-
270
- return v
271
-
272
-
273
- def empty(v: SizedT, msg: Message = None) -> SizedT:
274
- if len(v) != 0:
275
- _raise(
276
- ValueError,
277
- 'Must be empty',
278
- msg,
279
- _ArgsKwargs(v),
280
- render_fmt='%s',
281
- )
282
-
283
- return v
284
-
285
-
286
- def iterempty(v: ta.Iterable[T], msg: Message = None) -> ta.Iterable[T]:
287
- it = iter(v)
288
- try:
289
- next(it)
290
- except StopIteration:
291
- pass
292
- else:
293
- _raise(
294
- ValueError,
295
- 'Must be empty',
296
- msg,
297
- _ArgsKwargs(v),
298
- render_fmt='%s',
299
- )
300
-
301
- return v
302
-
303
-
304
- def not_empty(v: SizedT, msg: Message = None) -> SizedT:
305
- if len(v) == 0:
306
- _raise(
307
- ValueError,
308
- 'Must not be empty',
309
- msg,
310
- _ArgsKwargs(v),
311
- render_fmt='%s',
312
- )
313
-
314
- return v
315
-
316
-
317
- def unique(it: ta.Iterable[T], msg: Message = None) -> ta.Iterable[T]:
318
- dupes = [e for e, c in collections.Counter(it).items() if c > 1]
319
- if dupes:
320
- _raise(
321
- ValueError,
322
- 'Must be unique',
323
- msg,
324
- _ArgsKwargs(it, dupes),
325
- )
326
-
327
- return it
328
-
329
-
330
- def single(obj: ta.Iterable[T], message: Message = None) -> T:
331
- try:
332
- [value] = obj
333
- except ValueError:
334
- _raise(
335
- ValueError,
336
- 'Must be single',
337
- message,
338
- _ArgsKwargs(obj),
339
- render_fmt='%s',
340
- )
341
-
342
- return value
343
-
344
-
345
- def opt_single(obj: ta.Iterable[T], message: Message = None) -> T | None:
346
- it = iter(obj)
347
- try:
348
- value = next(it)
349
- except StopIteration:
350
- return None
351
-
352
- try:
353
- next(it)
354
- except StopIteration:
355
- return value # noqa
356
-
357
- _raise(
358
- ValueError,
359
- 'Must be empty or single',
360
- message,
361
- _ArgsKwargs(obj),
362
- render_fmt='%s',
363
- )
51
+ check.register_late_configure(_try_enable_args_rendering)
364
52
 
365
53
 
366
54
  ##
367
55
 
368
56
 
369
- def none(v: ta.Any, msg: Message = None) -> None:
370
- if v is not None:
371
- _raise(
372
- ValueError,
373
- 'Must be None',
374
- msg,
375
- _ArgsKwargs(v),
376
- render_fmt='%s',
377
- )
378
-
379
-
380
- def not_none(v: T | None, msg: Message = None) -> T:
381
- if v is None:
382
- _raise(
383
- ValueError,
384
- 'Must not be None',
385
- msg,
386
- _ArgsKwargs(v),
387
- render_fmt='%s',
388
- )
389
-
390
- return v
391
-
392
-
393
- ##
394
-
395
-
396
- def equal(v: T, o: ta.Any, msg: Message = None) -> T:
397
- if o != v:
398
- _raise(
399
- ValueError,
400
- 'Must be equal',
401
- msg,
402
- _ArgsKwargs(v, o),
403
- render_fmt='%s != %s',
404
- )
405
-
406
- return v
407
-
408
-
409
- def is_(v: T, o: ta.Any, msg: Message = None) -> T:
410
- if o is not v:
411
- _raise(
412
- ValueError,
413
- 'Must be the same',
414
- msg,
415
- _ArgsKwargs(v, o),
416
- render_fmt='%s is not %s',
417
- )
418
-
419
- return v
420
-
421
-
422
- def is_not(v: T, o: ta.Any, msg: Message = None) -> T:
423
- if o is v:
424
- _raise(
425
- ValueError,
426
- 'Must not be the same',
427
- msg,
428
- _ArgsKwargs(v, o),
429
- render_fmt='%s is %s',
430
- )
431
-
432
- return v
433
-
434
-
435
- def callable(v: T, msg: Message = None) -> T: # noqa
436
- if not _callable(v):
437
- _raise(
438
- TypeError,
439
- 'Must be callable',
440
- msg,
441
- _ArgsKwargs(v),
442
- render_fmt='%s',
443
- )
444
-
445
- return v # type: ignore
446
-
447
-
448
- def non_empty_str(v: str | None, msg: Message = None) -> str:
449
- if not _isinstance(v, str) or not v:
450
- _raise(
451
- ValueError,
452
- 'Must be non-empty str',
453
- msg,
454
- _ArgsKwargs(v),
455
- render_fmt='%s',
456
- )
457
-
458
- return v
57
+ isinstance = check.isinstance # noqa
58
+ of_isinstance = check.of_isinstance
59
+ cast = check.cast
60
+ of_cast = check.of_cast
61
+ not_isinstance = check.not_isinstance
62
+ of_not_isinstance = check.of_not_isinstance
459
63
 
64
+ #
460
65
 
461
- def replacing(expected: ta.Any, old: ta.Any, new: T, msg: Message = None) -> T:
462
- if old != expected:
463
- _raise(
464
- ValueError,
465
- 'Must be replacing',
466
- msg,
467
- _ArgsKwargs(expected, old, new),
468
- render_fmt='%s -> %s -> %s',
469
- )
66
+ issubclass = check.issubclass # noqa
67
+ not_issubclass = check.not_issubclass
470
68
 
471
- return new
69
+ #
472
70
 
71
+ in_ = check.in_
72
+ not_in = check.not_in
73
+ empty = check.empty
74
+ iterempty = check.iterempty
75
+ not_empty = check.not_empty
76
+ unique = check.unique
77
+ single = check.single
78
+ opt_single = check.opt_single
473
79
 
474
- def replacing_none(old: ta.Any, new: T, msg: Message = None) -> T:
475
- if old is not None:
476
- _raise(
477
- ValueError,
478
- 'Must be replacing None',
479
- msg,
480
- _ArgsKwargs(old, new),
481
- render_fmt='%s -> %s',
482
- )
80
+ #
483
81
 
484
- return new
82
+ none = check.none
83
+ not_none = check.not_none
485
84
 
85
+ #
486
86
 
487
- ##
87
+ equal = check.equal
88
+ is_ = check.is_
89
+ is_not = check.is_not
90
+ callable = check.callable # noqa
91
+ non_empty_str = check.non_empty_str
92
+ replacing = check.replacing
93
+ replacing_none = check.replacing_none
488
94
 
95
+ #
489
96
 
490
- def arg(v: bool, msg: Message = None) -> None:
491
- if not v:
492
- _raise(
493
- RuntimeError,
494
- 'Argument condition not met',
495
- msg,
496
- _ArgsKwargs(v),
497
- render_fmt='%s',
498
- )
499
-
500
-
501
- def state(v: bool, msg: Message = None) -> None:
502
- if not v:
503
- _raise(
504
- RuntimeError,
505
- 'State condition not met',
506
- msg,
507
- _ArgsKwargs(v),
508
- render_fmt='%s',
509
- )
97
+ arg = check.arg
98
+ state = check.state
@@ -0,0 +1,72 @@
1
+ from .base import ( # noqa
2
+ EagerCodec,
3
+ IncrementalCodec,
4
+ ComboCodec,
5
+
6
+ check_codec_name,
7
+
8
+ Codec,
9
+
10
+ LazyLoadedCodec,
11
+ )
12
+
13
+ from .bytes import ( # noqa
14
+ ASCII85,
15
+ BASE16,
16
+ BASE32,
17
+ BASE64,
18
+ BASE85,
19
+ BASE32_HEX,
20
+ BASE64_HEX,
21
+ BASE64_URLSAFE,
22
+ HEX,
23
+ )
24
+
25
+ from .chain import ( # noqa
26
+ ChainEagerCodec,
27
+
28
+ chain,
29
+ )
30
+
31
+ from .funcs import ( # noqa
32
+ FnPairEagerCodec,
33
+
34
+ of_pair,
35
+ of,
36
+ )
37
+
38
+ from .registry import ( # noqa
39
+ CodecRegistry,
40
+
41
+ REGISTRY,
42
+ register,
43
+ lookup,
44
+
45
+ encode,
46
+ decode,
47
+ )
48
+
49
+ from .standard import ( # noqa
50
+ STANDARD_CODECS,
51
+ )
52
+
53
+ from .text import ( # noqa
54
+ TextEncodingErrors,
55
+ TextEncodingOptions,
56
+
57
+ TextEncodingComboCodec,
58
+
59
+ TextEncodingCodec,
60
+
61
+ ASCII,
62
+ LATIN1,
63
+ UTF32,
64
+ UTF32BE,
65
+ UTF32LE,
66
+ UTF16,
67
+ UTF16BE,
68
+ UTF16LE,
69
+ UTF7,
70
+ UTF8,
71
+ UTF8SIG,
72
+ )