omlish 0.0.0.dev134__py3-none-any.whl → 0.0.0.dev135__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev134'
2
- __revision__ = '2ce79daa2fabaed83f01745229d814bc8aeb7628'
1
+ __version__ = '0.0.0.dev135'
2
+ __revision__ = 'bf47c29e2fe6b065c99ce565d89f133b798895d9'
3
3
 
4
4
 
5
5
  #
@@ -1,3 +1,4 @@
1
+ # ruff: noqa: UP006 UP007
1
2
  import socket
2
3
  import typing as ta
3
4
 
@@ -22,6 +23,7 @@ class CoroHttpServerConnectionFdIoHandler(SocketFdIoHandler):
22
23
  *,
23
24
  read_size: int = 0x10000,
24
25
  write_size: int = 0x10000,
26
+ log_handler: ta.Optional[ta.Callable[[CoroHttpServer, CoroHttpServer.AnyLogIo], None]] = None,
25
27
  ) -> None:
26
28
  check_state(not sock.getblocking())
27
29
 
@@ -30,6 +32,7 @@ class CoroHttpServerConnectionFdIoHandler(SocketFdIoHandler):
30
32
  self._handler = handler
31
33
  self._read_size = read_size
32
34
  self._write_size = write_size
35
+ self._log_handler = log_handler
33
36
 
34
37
  self._read_buf = ReadableListBuffer()
35
38
  self._write_buf: IncrementalWriteBuffer | None = None
@@ -64,7 +67,8 @@ class CoroHttpServerConnectionFdIoHandler(SocketFdIoHandler):
64
67
  break
65
68
 
66
69
  if isinstance(o, CoroHttpServer.AnyLogIo):
67
- print(o)
70
+ if self._log_handler is not None:
71
+ self._log_handler(self._coro_srv, o)
68
72
  o = None
69
73
 
70
74
  elif isinstance(o, CoroHttpServer.ReadIo):
omlish/lite/marshal.py CHANGED
@@ -165,6 +165,13 @@ class PolymorphicObjMarshaler(ObjMarshaler):
165
165
  impls_by_ty: ta.Mapping[type, Impl]
166
166
  impls_by_tag: ta.Mapping[str, Impl]
167
167
 
168
+ @classmethod
169
+ def of(cls, impls: ta.Iterable[Impl]) -> 'PolymorphicObjMarshaler':
170
+ return cls(
171
+ {i.ty: i for i in impls},
172
+ {i.tag: i for i in impls},
173
+ )
174
+
168
175
  def marshal(self, o: ta.Any) -> ta.Any:
169
176
  impl = self.impls_by_ty[type(o)]
170
177
  return {impl.tag: impl.m.marshal(o)}
@@ -252,7 +259,7 @@ def _make_obj_marshaler(
252
259
  ) -> ObjMarshaler:
253
260
  if isinstance(ty, type):
254
261
  if abc.ABC in ty.__bases__:
255
- impls = [ # type: ignore
262
+ return PolymorphicObjMarshaler.of([ # type: ignore
256
263
  PolymorphicObjMarshaler.Impl(
257
264
  ity,
258
265
  ity.__qualname__,
@@ -260,11 +267,7 @@ def _make_obj_marshaler(
260
267
  )
261
268
  for ity in deep_subclasses(ty)
262
269
  if abc.ABC not in ity.__bases__
263
- ]
264
- return PolymorphicObjMarshaler(
265
- {i.ty: i for i in impls},
266
- {i.tag: i for i in impls},
267
- )
270
+ ])
268
271
 
269
272
  if issubclass(ty, enum.Enum):
270
273
  return EnumObjMarshaler(ty)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omlish
3
- Version: 0.0.0.dev134
3
+ Version: 0.0.0.dev135
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.manifests.json,sha256=CxGnj-UiRPlZgmgWoovDWrOnqpSEmBy_kqA7cdfSA3w,1431
2
- omlish/__about__.py,sha256=VbiavsAPDxYSejJ3ZdJJNSJAID1MpR3SYmAYcFX-E2U,3379
2
+ omlish/__about__.py,sha256=v2e0yLh0hfZ_l8fAvWlrUY6UTj7j9U62ZZUsPMsDHPI,3379
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/argparse.py,sha256=cqKGAqcxuxv_s62z0gq29L9KAvg_3-_rFvXKjVpRJjo,8126
5
5
  omlish/c3.py,sha256=ubu7lHwss5V4UznbejAI0qXhXahrU01MysuHOZI9C4U,8116
@@ -308,7 +308,7 @@ omlish/lite/io.py,sha256=3ECgUXdRnXyS6pGTSoVr6oB4moI38EpWxTq08zaTM-U,5339
308
308
  omlish/lite/journald.py,sha256=f5Y2Q6-6O3iK_7MoGiwZwoQEOcP7LfkxxQNUR9tMjJM,3882
309
309
  omlish/lite/json.py,sha256=7-02Ny4fq-6YAu5ynvqoijhuYXWpLmfCI19GUeZnb1c,740
310
310
  omlish/lite/logs.py,sha256=1pcGu0ekhVCcLUckLSP16VccnAoprjtl5Vkdfm7y1Wg,6184
311
- omlish/lite/marshal.py,sha256=SyYMsJ-TaGO9FX7LykBB0WtqsqetX9eLBotPiz3M_xg,9478
311
+ omlish/lite/marshal.py,sha256=rAOAuJ4uGtcODxYR0YjhO6UGaFOdDuRXJcgTXdytBAw,9559
312
312
  omlish/lite/maybes.py,sha256=7OlHJ8Q2r4wQ-aRbZSlJY7x0e8gDvufFdlohGEIJ3P4,833
313
313
  omlish/lite/pidfile.py,sha256=PRSDOAXmNkNwxh-Vwif0Nrs8RAmWroiNhLKIbdjwzBc,1723
314
314
  omlish/lite/reflect.py,sha256=ad_ya_zZJOQB8HoNjs9yc66R54zgflwJVPJqiBXMzqA,1681
@@ -320,7 +320,7 @@ omlish/lite/strings.py,sha256=QURcE4-1pKVW8eT_5VCJpXaHDWR2dW2pYOChTJnZDiQ,1504
320
320
  omlish/lite/subprocesses.py,sha256=_YwUpvfaC2pV5TMC9-Ivuw1Ao-YxteD3a1NQwGERft4,3380
321
321
  omlish/lite/typing.py,sha256=U3-JaEnkDSYxK4tsu_MzUn3RP6qALBe5FXQXpD-licE,1090
322
322
  omlish/lite/fdio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
323
- omlish/lite/fdio/corohttp.py,sha256=5kzuM1cssA2D7rfknHFxylpjBNfA5tQSPkIRY2Ilapo,3825
323
+ omlish/lite/fdio/corohttp.py,sha256=VuS4IaAluMPgtl9iQnMnKQsEMlqruN6B1BKkTV0WWKk,4080
324
324
  omlish/lite/fdio/handlers.py,sha256=ukUiwF8-UCr4mzTTfOaTipC0k3k7THiHnohVdYfH69o,1341
325
325
  omlish/lite/fdio/kqueue.py,sha256=lIWvvRpRyak0dmzE6FPtCdS02HGo0EEI0D1g8cWyLYk,3832
326
326
  omlish/lite/fdio/manager.py,sha256=-gMVzk4B1YTZS-d2TdM12woUme37pcNVUxNTiLe91lA,1250
@@ -487,9 +487,9 @@ omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,329
487
487
  omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
488
488
  omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
489
489
  omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
490
- omlish-0.0.0.dev134.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
491
- omlish-0.0.0.dev134.dist-info/METADATA,sha256=L5wBl_EJCZwTtSLR1mK6J0GJ7kpHLt3w5U9UbbIWl3I,4173
492
- omlish-0.0.0.dev134.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
493
- omlish-0.0.0.dev134.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
494
- omlish-0.0.0.dev134.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
495
- omlish-0.0.0.dev134.dist-info/RECORD,,
490
+ omlish-0.0.0.dev135.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
491
+ omlish-0.0.0.dev135.dist-info/METADATA,sha256=FzsPMJSJzeIUc8mYwPYfE1NNy3xXUjCA3CiZllCo9xI,4173
492
+ omlish-0.0.0.dev135.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
493
+ omlish-0.0.0.dev135.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
494
+ omlish-0.0.0.dev135.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
495
+ omlish-0.0.0.dev135.dist-info/RECORD,,