omlish 0.0.0.dev279__py3-none-any.whl → 0.0.0.dev281__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.
- omlish/__about__.py +2 -2
- omlish/asyncs/anyio/subprocesses.py +85 -0
- omlish/collections/identity.py +6 -1
- omlish/dataclasses/impl/metaclass.py +0 -9
- {omlish-0.0.0.dev279.dist-info → omlish-0.0.0.dev281.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev279.dist-info → omlish-0.0.0.dev281.dist-info}/RECORD +10 -9
- {omlish-0.0.0.dev279.dist-info → omlish-0.0.0.dev281.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev279.dist-info → omlish-0.0.0.dev281.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev279.dist-info → omlish-0.0.0.dev281.dist-info}/licenses/LICENSE +0 -0
- {omlish-0.0.0.dev279.dist-info → omlish-0.0.0.dev281.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
import io
|
2
|
+
import subprocess
|
3
|
+
import sys
|
4
|
+
import typing as ta
|
5
|
+
|
6
|
+
import anyio.abc
|
7
|
+
|
8
|
+
from ... import check
|
9
|
+
from ...lite.timeouts import Timeout
|
10
|
+
from ...subprocesses.async_ import AbstractAsyncSubprocesses
|
11
|
+
from ...subprocesses.run import SubprocessRun
|
12
|
+
from ...subprocesses.run import SubprocessRunOutput
|
13
|
+
|
14
|
+
|
15
|
+
T = ta.TypeVar('T')
|
16
|
+
|
17
|
+
|
18
|
+
##
|
19
|
+
|
20
|
+
|
21
|
+
class AnyioSubprocesses(AbstractAsyncSubprocesses):
|
22
|
+
async def run_(self, run: SubprocessRun) -> SubprocessRunOutput:
|
23
|
+
kwargs = dict(run.kwargs or {})
|
24
|
+
|
25
|
+
if run.capture_output:
|
26
|
+
kwargs.setdefault('stdout', subprocess.PIPE)
|
27
|
+
kwargs.setdefault('stderr', subprocess.PIPE)
|
28
|
+
|
29
|
+
with anyio.fail_after(Timeout.of(run.timeout).or_(None)):
|
30
|
+
async with await anyio.open_process(
|
31
|
+
run.cmd,
|
32
|
+
**kwargs,
|
33
|
+
) as proc:
|
34
|
+
async def read_output(stream: anyio.abc.ByteReceiveStream, writer: ta.IO) -> None:
|
35
|
+
while True:
|
36
|
+
try:
|
37
|
+
data = await stream.receive()
|
38
|
+
except anyio.EndOfStream:
|
39
|
+
return
|
40
|
+
writer.write(data)
|
41
|
+
|
42
|
+
stdout: io.BytesIO | None = None
|
43
|
+
stderr: io.BytesIO | None = None
|
44
|
+
async with anyio.create_task_group() as tg:
|
45
|
+
if proc.stdout is not None:
|
46
|
+
stdout = io.BytesIO()
|
47
|
+
tg.start_soon(read_output, proc.stdout, stdout)
|
48
|
+
|
49
|
+
if proc.stderr is not None:
|
50
|
+
stderr = io.BytesIO()
|
51
|
+
tg.start_soon(read_output, proc.stderr, stderr)
|
52
|
+
|
53
|
+
if proc.stdin and run.input is not None:
|
54
|
+
await proc.stdin.send(run.input)
|
55
|
+
await proc.stdin.aclose()
|
56
|
+
|
57
|
+
await proc.wait()
|
58
|
+
|
59
|
+
if run.check and proc.returncode != 0:
|
60
|
+
raise subprocess.CalledProcessError(
|
61
|
+
ta.cast(int, proc.returncode),
|
62
|
+
run.cmd,
|
63
|
+
stdout.getvalue() if stdout is not None else None,
|
64
|
+
stderr.getvalue() if stderr is not None else None,
|
65
|
+
)
|
66
|
+
|
67
|
+
return SubprocessRunOutput(
|
68
|
+
proc=proc,
|
69
|
+
|
70
|
+
returncode=check.isinstance(proc.returncode, int),
|
71
|
+
|
72
|
+
stdout=stdout.getvalue() if stdout is not None else None,
|
73
|
+
stderr=stderr.getvalue() if stderr is not None else None,
|
74
|
+
)
|
75
|
+
|
76
|
+
async def check_call(self, *cmd: str, stdout: ta.Any = sys.stderr, **kwargs: ta.Any) -> None:
|
77
|
+
with self.prepare_and_wrap(*cmd, stdout=stdout, check=True, **kwargs) as (cmd, kwargs): # noqa
|
78
|
+
await self.run(*cmd, **kwargs)
|
79
|
+
|
80
|
+
async def check_output(self, *cmd: str, **kwargs: ta.Any) -> bytes:
|
81
|
+
with self.prepare_and_wrap(*cmd, stdout=subprocess.PIPE, check=True, **kwargs) as (cmd, kwargs): # noqa
|
82
|
+
return check.not_none((await self.run(*cmd, **kwargs)).stdout)
|
83
|
+
|
84
|
+
|
85
|
+
anyio_subprocesses = AnyioSubprocesses()
|
omlish/collections/identity.py
CHANGED
@@ -122,6 +122,7 @@ class IdentityWeakSet(ta.MutableSet[T]):
|
|
122
122
|
self._dict: weakref.WeakValueDictionary[int, T] = weakref.WeakValueDictionary()
|
123
123
|
|
124
124
|
def add(self, value):
|
125
|
+
# FIXME: race with weakref callback?
|
125
126
|
self._dict[id(value)] = value
|
126
127
|
|
127
128
|
def discard(self, value):
|
@@ -131,7 +132,11 @@ class IdentityWeakSet(ta.MutableSet[T]):
|
|
131
132
|
pass
|
132
133
|
|
133
134
|
def __contains__(self, x):
|
134
|
-
|
135
|
+
try:
|
136
|
+
o = self._dict[id(x)]
|
137
|
+
except KeyError:
|
138
|
+
return False
|
139
|
+
return x is o
|
135
140
|
|
136
141
|
def __len__(self):
|
137
142
|
return len(self._dict)
|
@@ -196,15 +196,6 @@ class Data(
|
|
196
196
|
# Typechecking barrier
|
197
197
|
super().__init_subclass__(**kwargs)
|
198
198
|
|
199
|
-
def __post_init__(self, *args, **kwargs) -> None:
|
200
|
-
try:
|
201
|
-
spi = super().__post_init__ # type: ignore # noqa
|
202
|
-
except AttributeError:
|
203
|
-
if args or kwargs:
|
204
|
-
raise TypeError(args, kwargs) from None
|
205
|
-
else:
|
206
|
-
spi(*args, **kwargs)
|
207
|
-
|
208
199
|
|
209
200
|
class Frozen(
|
210
201
|
Data,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=pjGUyLHaoWpPqRP3jz2u1fC1qoRc2lvrEcpU_Ax2tdg,8253
|
2
|
-
omlish/__about__.py,sha256
|
2
|
+
omlish/__about__.py,sha256=m6XQHqqI6rUpgAsxCnQeK9geiNgmq4O_6PM4kkZaSeY,3380
|
3
3
|
omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
|
4
4
|
omlish/c3.py,sha256=rer-TPOFDU6fYq_AWio_AmA-ckZ8JDY5shIzQ_yXfzA,8414
|
5
5
|
omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
|
@@ -102,6 +102,7 @@ omlish/asyncs/anyio/backends.py,sha256=jJIymWoiedaEJJm82gvKiJ41EWLQZ-bcyNHpbDpKK
|
|
102
102
|
omlish/asyncs/anyio/futures.py,sha256=Nm1gLerZEnHk-rlsmr0UfK168IWIK6zA8EebZFtoY_E,2052
|
103
103
|
omlish/asyncs/anyio/signals.py,sha256=ySSut5prdnoy0-5Ws5V1M4cC2ON_vY550vU10d2NHk8,893
|
104
104
|
omlish/asyncs/anyio/streams.py,sha256=gNRAcHR0L8OtNioqKFbq0Z_apYAWKHFipZ2MUBp8Vg0,2228
|
105
|
+
omlish/asyncs/anyio/subprocesses.py,sha256=jjMjlcwtIiy-_y-spPn3eTC5dzrqFNSAMTPaIcXH9S8,3002
|
105
106
|
omlish/asyncs/anyio/sync.py,sha256=ZmSNhSsEkPwlXThrpefhtVTxw4GJ9F0P-yKyo5vbbSk,1574
|
106
107
|
omlish/asyncs/anyio/utils.py,sha256=X2Rz1DGrCJ0zkt1O5cHoMRaYKTPndBj6dzLhb09mVtE,1672
|
107
108
|
omlish/asyncs/asyncio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -149,7 +150,7 @@ omlish/collections/coerce.py,sha256=tAls15v_7p5bUN33R7Zbko87KW5toWHl9fRialCqyNY,
|
|
149
150
|
omlish/collections/exceptions.py,sha256=shcS-NCnEUudF8qC_SmO2TQyjivKlS4TDjaz_faqQ0c,44
|
150
151
|
omlish/collections/frozen.py,sha256=LMbAHYDENIQk1hvjCTvpnx66m1TalrHa4CSn8n_tsXQ,4142
|
151
152
|
omlish/collections/hasheq.py,sha256=swOBPEnU_C0SU3VqWJX9mr0BfZLD0A-4Ke9Vahj3fE4,3669
|
152
|
-
omlish/collections/identity.py,sha256=
|
153
|
+
omlish/collections/identity.py,sha256=xtoczgBPYzr6r2lJS-eti2kEnN8rVDvNGDCG3TA6vRo,3405
|
153
154
|
omlish/collections/mappings.py,sha256=u0UrB550nBM_RNXQV0YnBTbRZEWrplZe9ZxcCN3H65M,2789
|
154
155
|
omlish/collections/ordered.py,sha256=7zTbrAt12rf6i33XHkQERKar258fJacaw_WbtGEBgWo,2338
|
155
156
|
omlish/collections/ranked.py,sha256=rg6DL36oOUiG5JQEAkGnT8b6f9mSndQlIovtt8GQj_w,2229
|
@@ -217,7 +218,7 @@ omlish/dataclasses/impl/hashing.py,sha256=0Gr6XIRkKy4pr-mdHblIlQCy3mBxycjMqJk3oZ
|
|
217
218
|
omlish/dataclasses/impl/init.py,sha256=CUM8Gnx171D3NO6FN4mlrIBoTcYiDqj_tqE9_NKKicg,6409
|
218
219
|
omlish/dataclasses/impl/internals.py,sha256=UvZYjrLT1S8ntyxJ_vRPIkPOF00K8HatGAygErgoXTU,2990
|
219
220
|
omlish/dataclasses/impl/main.py,sha256=bWnqEDOfITjEwkLokTvOegp88KaQXJFun3krgxt3aE0,2647
|
220
|
-
omlish/dataclasses/impl/metaclass.py,sha256=
|
221
|
+
omlish/dataclasses/impl/metaclass.py,sha256=rhcMHNJYISgMkC95Yq14aLEs48iK9Rzma5yb7-4mPIk,4965
|
221
222
|
omlish/dataclasses/impl/metadata.py,sha256=4veWwTr-aA0KP-Y1cPEeOcXHup9EKJTYNJ0ozIxtzD4,1401
|
222
223
|
omlish/dataclasses/impl/order.py,sha256=zWvWDkSTym8cc7vO1cLHqcBhhjOlucHOCUVJcdh4jt0,1369
|
223
224
|
omlish/dataclasses/impl/overrides.py,sha256=g9aCzaDDKyek8-yXRvtAcu1B1nCphWDYr4InHDlgbKk,1732
|
@@ -788,9 +789,9 @@ omlish/typedvalues/holder.py,sha256=4SwRezsmuDDEO5gENGx8kTm30pblF5UktoEAu02i-Gk,
|
|
788
789
|
omlish/typedvalues/marshal.py,sha256=eWMrmuzPk3pX5AlILc5YBvuJBUHRQA_vwkxRm5aHiGs,4209
|
789
790
|
omlish/typedvalues/reflect.py,sha256=y_7IY8_4cLVRvD3ug-_-cDaO5RtzC1rLVFzkeAPALf8,683
|
790
791
|
omlish/typedvalues/values.py,sha256=Acyf6xSdNHxrkRXLXrFqJouk35YOveso1VqTbyPwQW4,1223
|
791
|
-
omlish-0.0.0.
|
792
|
-
omlish-0.0.0.
|
793
|
-
omlish-0.0.0.
|
794
|
-
omlish-0.0.0.
|
795
|
-
omlish-0.0.0.
|
796
|
-
omlish-0.0.0.
|
792
|
+
omlish-0.0.0.dev281.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
793
|
+
omlish-0.0.0.dev281.dist-info/METADATA,sha256=WbM1Pt11bpMSbD2fXF9cEe_oZCKQy0EJ56gN1bKx5dE,4198
|
794
|
+
omlish-0.0.0.dev281.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
795
|
+
omlish-0.0.0.dev281.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
796
|
+
omlish-0.0.0.dev281.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
797
|
+
omlish-0.0.0.dev281.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|