omlish 0.0.0.dev131__py3-none-any.whl → 0.0.0.dev132__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- omlish/__about__.py +2 -2
- omlish/lite/contextmanagers.py +8 -0
- omlish/lite/fdio/kqueue.py +29 -7
- omlish/lite/fdio/pollers.py +12 -12
- omlish/reflect/__init__.py +0 -5
- {omlish-0.0.0.dev131.dist-info → omlish-0.0.0.dev132.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev131.dist-info → omlish-0.0.0.dev132.dist-info}/RECORD +11 -12
- omlish/reflect/isinstance.py +0 -38
- {omlish-0.0.0.dev131.dist-info → omlish-0.0.0.dev132.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev131.dist-info → omlish-0.0.0.dev132.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev131.dist-info → omlish-0.0.0.dev132.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev131.dist-info → omlish-0.0.0.dev132.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/lite/contextmanagers.py
CHANGED
@@ -39,6 +39,14 @@ class ExitStacked:
|
|
39
39
|
##
|
40
40
|
|
41
41
|
|
42
|
+
@contextlib.contextmanager
|
43
|
+
def defer(fn: ta.Callable) -> ta.Generator[ta.Callable, None, None]:
|
44
|
+
try:
|
45
|
+
yield fn
|
46
|
+
finally:
|
47
|
+
fn()
|
48
|
+
|
49
|
+
|
42
50
|
@contextlib.contextmanager
|
43
51
|
def attr_setting(obj, attr, val, *, default=None): # noqa
|
44
52
|
not_set = object()
|
omlish/lite/fdio/kqueue.py
CHANGED
@@ -47,19 +47,40 @@ if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
|
|
47
47
|
#
|
48
48
|
|
49
49
|
def _register_readable(self, fd: int) -> None:
|
50
|
-
self.
|
50
|
+
self._update_registration(fd, 'read', 'add')
|
51
51
|
|
52
52
|
def _register_writable(self, fd: int) -> None:
|
53
|
-
self.
|
53
|
+
self._update_registration(fd, 'write', 'add')
|
54
54
|
|
55
55
|
def _unregister_readable(self, fd: int) -> None:
|
56
|
-
self.
|
56
|
+
self._update_registration(fd, 'read', 'del')
|
57
57
|
|
58
58
|
def _unregister_writable(self, fd: int) -> None:
|
59
|
-
self.
|
59
|
+
self._update_registration(fd, 'write', 'del')
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
#
|
62
|
+
|
63
|
+
_CONTROL_FILTER_BY_READ_OR_WRITE: ta.ClassVar[ta.Mapping[ta.Literal['read', 'write'], int]] = {
|
64
|
+
'read': select.KQ_FILTER_READ,
|
65
|
+
'write': select.KQ_FILTER_WRITE,
|
66
|
+
}
|
67
|
+
|
68
|
+
_CONTROL_FLAGS_BY_ADD_OR_DEL: ta.ClassVar[ta.Mapping[ta.Literal['add', 'del'], int]] = {
|
69
|
+
'add': select.KQ_EV_ADD,
|
70
|
+
'del': select.KQ_EV_DELETE,
|
71
|
+
}
|
72
|
+
|
73
|
+
def _update_registration(
|
74
|
+
self,
|
75
|
+
fd: int,
|
76
|
+
read_or_write: ta.Literal['read', 'write'],
|
77
|
+
add_or_del: ta.Literal['add', 'del'],
|
78
|
+
) -> None: # noqa
|
79
|
+
ke = select.kevent(
|
80
|
+
fd,
|
81
|
+
filter=self._CONTROL_FILTER_BY_READ_OR_WRITE[read_or_write],
|
82
|
+
flags=self._CONTROL_FLAGS_BY_ADD_OR_DEL[add_or_del],
|
83
|
+
)
|
63
84
|
kq = self._get_kqueue()
|
64
85
|
try:
|
65
86
|
kq.control([ke], 0)
|
@@ -70,7 +91,8 @@ if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
|
|
70
91
|
pass
|
71
92
|
elif exc.errno == errno.ENOENT:
|
72
93
|
# Can happen when trying to remove an already closed socket
|
73
|
-
|
94
|
+
if add_or_del == 'add':
|
95
|
+
raise
|
74
96
|
else:
|
75
97
|
raise
|
76
98
|
|
omlish/lite/fdio/pollers.py
CHANGED
@@ -42,16 +42,16 @@ class FdIoPoller(abc.ABC):
|
|
42
42
|
def register_readable(self, fd: int) -> bool:
|
43
43
|
if fd in self._readable:
|
44
44
|
return False
|
45
|
-
self._readable.add(fd)
|
46
45
|
self._register_readable(fd)
|
46
|
+
self._readable.add(fd)
|
47
47
|
return True
|
48
48
|
|
49
49
|
@ta.final
|
50
50
|
def register_writable(self, fd: int) -> bool:
|
51
51
|
if fd in self._writable:
|
52
52
|
return False
|
53
|
-
self._writable.add(fd)
|
54
53
|
self._register_writable(fd)
|
54
|
+
self._writable.add(fd)
|
55
55
|
return True
|
56
56
|
|
57
57
|
@ta.final
|
@@ -155,24 +155,24 @@ if hasattr(select, 'poll'):
|
|
155
155
|
|
156
156
|
#
|
157
157
|
|
158
|
-
_READ = select.POLLIN | select.POLLPRI | select.POLLHUP
|
159
|
-
_WRITE = select.POLLOUT
|
160
|
-
|
161
158
|
def _register_readable(self, fd: int) -> None:
|
162
|
-
self._update_registration(fd)
|
159
|
+
self._update_registration(fd, r=True, w=fd in self._writable)
|
163
160
|
|
164
161
|
def _register_writable(self, fd: int) -> None:
|
165
|
-
self._update_registration(fd)
|
162
|
+
self._update_registration(fd, r=fd in self._readable, w=True)
|
166
163
|
|
167
164
|
def _unregister_readable(self, fd: int) -> None:
|
168
|
-
self._update_registration(fd)
|
165
|
+
self._update_registration(fd, r=False, w=False)
|
169
166
|
|
170
167
|
def _unregister_writable(self, fd: int) -> None:
|
171
|
-
self._update_registration(fd)
|
168
|
+
self._update_registration(fd, r=fd in self._readable, w=False)
|
169
|
+
|
170
|
+
#
|
171
|
+
|
172
|
+
_READ = select.POLLIN | select.POLLPRI | select.POLLHUP
|
173
|
+
_WRITE = select.POLLOUT
|
172
174
|
|
173
|
-
def _update_registration(self, fd: int) -> None:
|
174
|
-
r = fd in self._readable
|
175
|
-
w = fd in self._writable
|
175
|
+
def _update_registration(self, fd: int, *, r: bool, w: bool) -> None:
|
176
176
|
if r or w:
|
177
177
|
self._poller.register(fd, (self._READ if r else 0) | (self._WRITE if w else 0))
|
178
178
|
else:
|
omlish/reflect/__init__.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=CxGnj-UiRPlZgmgWoovDWrOnqpSEmBy_kqA7cdfSA3w,1431
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=Hh57Z8Q9ObeU2bHvFw6jTo7TCwcIpEOagKGqhUHHeSY,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
|
@@ -301,7 +301,7 @@ omlish/lifecycles/transitions.py,sha256=qQtFby-h4VzbvgaUqT2NnbNumlcOx9FVVADP9t83
|
|
301
301
|
omlish/lite/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
302
302
|
omlish/lite/cached.py,sha256=Fs-ljXVJmHBjAaHc-JuJXMEV4MNSX5c_KHZIM3AEaIw,694
|
303
303
|
omlish/lite/check.py,sha256=pQC412ffe_Zh7eHa4C1UYn6fA71Ls1vpVM0ZIOroPAY,1765
|
304
|
-
omlish/lite/contextmanagers.py,sha256=
|
304
|
+
omlish/lite/contextmanagers.py,sha256=DRarS2gx15tbse1YzyI8ZLdBmWYjFgmKPe-i4CSNDYg,1458
|
305
305
|
omlish/lite/docker.py,sha256=3IVZZtIm7-UdB2SwArmN_MosTva1_KifyYp3YWjODbE,337
|
306
306
|
omlish/lite/inject.py,sha256=aRRmFb6azTKF208ogYwVCEopNZx7496Ta1GZmL_IKBA,23716
|
307
307
|
omlish/lite/io.py,sha256=3ECgUXdRnXyS6pGTSoVr6oB4moI38EpWxTq08zaTM-U,5339
|
@@ -322,9 +322,9 @@ omlish/lite/typing.py,sha256=U3-JaEnkDSYxK4tsu_MzUn3RP6qALBe5FXQXpD-licE,1090
|
|
322
322
|
omlish/lite/fdio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
323
323
|
omlish/lite/fdio/corohttp.py,sha256=5kzuM1cssA2D7rfknHFxylpjBNfA5tQSPkIRY2Ilapo,3825
|
324
324
|
omlish/lite/fdio/handlers.py,sha256=ukUiwF8-UCr4mzTTfOaTipC0k3k7THiHnohVdYfH69o,1341
|
325
|
-
omlish/lite/fdio/kqueue.py,sha256=
|
325
|
+
omlish/lite/fdio/kqueue.py,sha256=lIWvvRpRyak0dmzE6FPtCdS02HGo0EEI0D1g8cWyLYk,3832
|
326
326
|
omlish/lite/fdio/manager.py,sha256=-gMVzk4B1YTZS-d2TdM12woUme37pcNVUxNTiLe91lA,1250
|
327
|
-
omlish/lite/fdio/pollers.py,sha256=
|
327
|
+
omlish/lite/fdio/pollers.py,sha256=d73P2ynzFdQZhmxhMKghzO6zvLwzTMSaIgBi7wQ5IQs,5507
|
328
328
|
omlish/lite/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
329
329
|
omlish/lite/http/coroserver.py,sha256=aBaYjP80yQHQxPxwi7PTYHub-fdRDKsMnB-tM8lBc2o,18095
|
330
330
|
omlish/lite/http/handlers.py,sha256=Yu0P3nqz-frklwCM2PbiWvoJNE-NqeTFLBvpNpqcdtA,753
|
@@ -371,9 +371,8 @@ omlish/math/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
371
371
|
omlish/math/bits.py,sha256=yip1l8agOYzT7bFyMGc0RR3XlnGCfHMpjw_SECLLh1I,3477
|
372
372
|
omlish/math/floats.py,sha256=UimhOT7KRl8LXTzOI5cQWoX_9h6WNWe_3vcOuO7-h_8,327
|
373
373
|
omlish/math/stats.py,sha256=MegzKVsmv2kra4jDWLOUgV0X7Ee2Tbl5u6ql1v4-dEY,10053
|
374
|
-
omlish/reflect/__init__.py,sha256=
|
374
|
+
omlish/reflect/__init__.py,sha256=4-EuCSX1qpEWfScCFzAJv_XghHFu4cXxpxKeBKrosQ4,720
|
375
375
|
omlish/reflect/inspect.py,sha256=veJ424-9oZrqyvhVpvxOi7hcKW-PDBkdYL2yjrFlk4o,495
|
376
|
-
omlish/reflect/isinstance.py,sha256=x5T9S2634leinBT4hl3CZZkRttvdvvlxChkC_x9Qu2s,1176
|
377
376
|
omlish/reflect/ops.py,sha256=RJ6jzrM4ieFsXzWyNXWV43O_WgzEaUvlHSc5N2ezW2A,2044
|
378
377
|
omlish/reflect/subst.py,sha256=JM2RGv2-Rcex8wCqhmgvRG59zD242P9jM3O2QLjKWWo,3586
|
379
378
|
omlish/reflect/types.py,sha256=B1zbq3yHo6B5JeNOXbmaxm78kqZTRb_4jIWY5GxzY4Q,8155
|
@@ -488,9 +487,9 @@ omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,329
|
|
488
487
|
omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
|
489
488
|
omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
|
490
489
|
omlish/text/random.py,sha256=jNWpqiaKjKyTdMXC-pWAsSC10AAP-cmRRPVhm59ZWLk,194
|
491
|
-
omlish-0.0.0.
|
492
|
-
omlish-0.0.0.
|
493
|
-
omlish-0.0.0.
|
494
|
-
omlish-0.0.0.
|
495
|
-
omlish-0.0.0.
|
496
|
-
omlish-0.0.0.
|
490
|
+
omlish-0.0.0.dev132.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
491
|
+
omlish-0.0.0.dev132.dist-info/METADATA,sha256=U0vjPiqK-XsyKsfbDGsCfEohWsGbsg4RMcv1rQ8jdL4,4173
|
492
|
+
omlish-0.0.0.dev132.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
493
|
+
omlish-0.0.0.dev132.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
494
|
+
omlish-0.0.0.dev132.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
495
|
+
omlish-0.0.0.dev132.dist-info/RECORD,,
|
omlish/reflect/isinstance.py
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import collections.abc
|
2
|
-
import typing as ta
|
3
|
-
|
4
|
-
from .ops import get_underlying
|
5
|
-
from .types import Generic
|
6
|
-
from .types import NewType
|
7
|
-
from .types import Type
|
8
|
-
from .types import Union
|
9
|
-
|
10
|
-
|
11
|
-
KNOWN_ISINSTANCE_GENERICS: ta.AbstractSet[type] = frozenset([
|
12
|
-
collections.abc.Mapping,
|
13
|
-
collections.abc.Sequence,
|
14
|
-
collections.abc.Set,
|
15
|
-
])
|
16
|
-
|
17
|
-
|
18
|
-
def isinstance_of(rfl: Type) -> ta.Callable[[ta.Any], bool]:
|
19
|
-
if isinstance(rfl, type):
|
20
|
-
return lambda o: isinstance(o, rfl)
|
21
|
-
|
22
|
-
if isinstance(rfl, NewType):
|
23
|
-
return isinstance_of(get_underlying(rfl))
|
24
|
-
|
25
|
-
if isinstance(rfl, Union):
|
26
|
-
fns = [isinstance_of(a) for a in rfl.args]
|
27
|
-
return lambda o: any(fn(o) for fn in fns)
|
28
|
-
|
29
|
-
if isinstance(rfl, Generic):
|
30
|
-
if rfl.cls in (collections.abc.Sequence, collections.abc.Set):
|
31
|
-
[efn] = map(isinstance_of, rfl.args)
|
32
|
-
return lambda o: isinstance(o, rfl.cls) and all(efn(e) for e in o) # type: ignore
|
33
|
-
|
34
|
-
if rfl.cls == collections.abc.Mapping:
|
35
|
-
kfn, vfn = map(isinstance_of, rfl.args)
|
36
|
-
return lambda o: isinstance(o, rfl.cls) and all(kfn(k) and vfn(v) for k, v in o.items()) # type: ignore
|
37
|
-
|
38
|
-
raise TypeError(rfl)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|