ominfra 0.0.0.dev128__tar.gz → 0.0.0.dev130__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {ominfra-0.0.0.dev128/ominfra.egg-info → ominfra-0.0.0.dev130}/PKG-INFO +3 -3
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/_executor.py +39 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/pyremote/_runcommands.py +39 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/scripts/journald2aws.py +136 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/scripts/supervisor.py +1732 -880
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/dispatchers.py +10 -9
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/dispatchersimpl.py +20 -18
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/groups.py +16 -1
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/groupsimpl.py +2 -2
- ominfra-0.0.0.dev130/ominfra/supervisor/http.py +130 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/inject.py +61 -17
- ominfra-0.0.0.dev130/ominfra/supervisor/io.py +97 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/main.py +5 -6
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/processimpl.py +10 -18
- ominfra-0.0.0.dev130/ominfra/supervisor/signals.py +66 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/spawningimpl.py +11 -11
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/supervisor.py +70 -137
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/types.py +21 -58
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130/ominfra.egg-info}/PKG-INFO +3 -3
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra.egg-info/SOURCES.txt +3 -2
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra.egg-info/requires.txt +2 -2
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/pyproject.toml +3 -3
- ominfra-0.0.0.dev128/ominfra/supervisor/context.py +0 -80
- ominfra-0.0.0.dev128/ominfra/supervisor/poller.py +0 -240
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/LICENSE +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/MANIFEST.in +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/README.rst +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/.manifests.json +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/__about__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/__main__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/auth.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/cli.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/dataclasses.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/journald2aws/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/journald2aws/__main__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/journald2aws/cursor.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/journald2aws/driver.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/journald2aws/main.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/journald2aws/poster.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/logs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/aws/metadata.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/gcp/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/clouds/gcp/auth.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/cmds.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/configs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/configs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/base.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/dirs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/nginx.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/repo.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/supervisor.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/systemd.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/user.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/concerns/venv.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/executor/main.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/_main.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/base.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/configs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/deploy.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/main.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/nginx.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/repo.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/runtime.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/site.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/supervisor.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/poly/venv.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/deploy/remote.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/journald/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/journald/fields.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/journald/genmessages.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/journald/messages.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/journald/tailer.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/manage/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/manage/manage.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/pyremote/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/pyremote/bootstrap.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/pyremote/runcommands.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/scripts/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/ssh.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/LICENSE.txt +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/__main__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/configs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/events.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/exceptions.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/pipes.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/privileges.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/process.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/setup.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/setupimpl.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/spawning.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/states.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/collections.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/diag.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/fds.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/fs.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/os.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/ostypes.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/signals.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/strings.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/supervisor/utils/users.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/tailscale/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/tailscale/api.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/tailscale/cli.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/threadworkers.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/tools/__init__.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra/tools/listresources.py +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra.egg-info/dependency_links.txt +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra.egg-info/entry_points.txt +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/ominfra.egg-info/top_level.txt +0 -0
- {ominfra-0.0.0.dev128 → ominfra-0.0.0.dev130}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev130
|
4
4
|
Summary: ominfra
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omdev==0.0.0.
|
16
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omdev==0.0.0.dev130
|
16
|
+
Requires-Dist: omlish==0.0.0.dev130
|
17
17
|
Provides-Extra: all
|
18
18
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
19
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -85,6 +85,9 @@ if sys.version_info < (3, 8):
|
|
85
85
|
# ../../../../omlish/lite/cached.py
|
86
86
|
T = ta.TypeVar('T')
|
87
87
|
|
88
|
+
# ../../../../omlish/lite/check.py
|
89
|
+
SizedT = ta.TypeVar('SizedT', bound=ta.Sized)
|
90
|
+
|
88
91
|
|
89
92
|
########################################
|
90
93
|
# ../../configs.py
|
@@ -189,11 +192,47 @@ def check_not_equal(l: T, r: T) -> T:
|
|
189
192
|
return l
|
190
193
|
|
191
194
|
|
195
|
+
def check_is(l: T, r: T) -> T:
|
196
|
+
if l is not r:
|
197
|
+
raise ValueError(l, r)
|
198
|
+
return l
|
199
|
+
|
200
|
+
|
201
|
+
def check_is_not(l: T, r: ta.Any) -> T:
|
202
|
+
if l is r:
|
203
|
+
raise ValueError(l, r)
|
204
|
+
return l
|
205
|
+
|
206
|
+
|
207
|
+
def check_in(v: T, c: ta.Container[T]) -> T:
|
208
|
+
if v not in c:
|
209
|
+
raise ValueError(v, c)
|
210
|
+
return v
|
211
|
+
|
212
|
+
|
213
|
+
def check_not_in(v: T, c: ta.Container[T]) -> T:
|
214
|
+
if v in c:
|
215
|
+
raise ValueError(v, c)
|
216
|
+
return v
|
217
|
+
|
218
|
+
|
192
219
|
def check_single(vs: ta.Iterable[T]) -> T:
|
193
220
|
[v] = vs
|
194
221
|
return v
|
195
222
|
|
196
223
|
|
224
|
+
def check_empty(v: SizedT) -> SizedT:
|
225
|
+
if len(v):
|
226
|
+
raise ValueError(v)
|
227
|
+
return v
|
228
|
+
|
229
|
+
|
230
|
+
def check_non_empty(v: SizedT) -> SizedT:
|
231
|
+
if not len(v):
|
232
|
+
raise ValueError(v)
|
233
|
+
return v
|
234
|
+
|
235
|
+
|
197
236
|
########################################
|
198
237
|
# ../../../../omlish/lite/json.py
|
199
238
|
|
@@ -44,6 +44,9 @@ if sys.version_info < (3, 8):
|
|
44
44
|
# ../../../omlish/lite/cached.py
|
45
45
|
T = ta.TypeVar('T')
|
46
46
|
|
47
|
+
# ../../../omlish/lite/check.py
|
48
|
+
SizedT = ta.TypeVar('SizedT', bound=ta.Sized)
|
49
|
+
|
47
50
|
|
48
51
|
########################################
|
49
52
|
# ../bootstrap.py
|
@@ -272,11 +275,47 @@ def check_not_equal(l: T, r: T) -> T:
|
|
272
275
|
return l
|
273
276
|
|
274
277
|
|
278
|
+
def check_is(l: T, r: T) -> T:
|
279
|
+
if l is not r:
|
280
|
+
raise ValueError(l, r)
|
281
|
+
return l
|
282
|
+
|
283
|
+
|
284
|
+
def check_is_not(l: T, r: ta.Any) -> T:
|
285
|
+
if l is r:
|
286
|
+
raise ValueError(l, r)
|
287
|
+
return l
|
288
|
+
|
289
|
+
|
290
|
+
def check_in(v: T, c: ta.Container[T]) -> T:
|
291
|
+
if v not in c:
|
292
|
+
raise ValueError(v, c)
|
293
|
+
return v
|
294
|
+
|
295
|
+
|
296
|
+
def check_not_in(v: T, c: ta.Container[T]) -> T:
|
297
|
+
if v in c:
|
298
|
+
raise ValueError(v, c)
|
299
|
+
return v
|
300
|
+
|
301
|
+
|
275
302
|
def check_single(vs: ta.Iterable[T]) -> T:
|
276
303
|
[v] = vs
|
277
304
|
return v
|
278
305
|
|
279
306
|
|
307
|
+
def check_empty(v: SizedT) -> SizedT:
|
308
|
+
if len(v):
|
309
|
+
raise ValueError(v)
|
310
|
+
return v
|
311
|
+
|
312
|
+
|
313
|
+
def check_non_empty(v: SizedT) -> SizedT:
|
314
|
+
if not len(v):
|
315
|
+
raise ValueError(v)
|
316
|
+
return v
|
317
|
+
|
318
|
+
|
280
319
|
########################################
|
281
320
|
# ../../../omlish/lite/json.py
|
282
321
|
|
@@ -59,6 +59,9 @@ TomlPos = int # ta.TypeAlias
|
|
59
59
|
# ../../../../../omlish/lite/cached.py
|
60
60
|
T = ta.TypeVar('T')
|
61
61
|
|
62
|
+
# ../../../../../omlish/lite/check.py
|
63
|
+
SizedT = ta.TypeVar('SizedT', bound=ta.Sized)
|
64
|
+
|
62
65
|
# ../../../../../omlish/lite/contextmanagers.py
|
63
66
|
ExitStackedT = ta.TypeVar('ExitStackedT', bound='ExitStacked')
|
64
67
|
|
@@ -968,11 +971,47 @@ def check_not_equal(l: T, r: T) -> T:
|
|
968
971
|
return l
|
969
972
|
|
970
973
|
|
974
|
+
def check_is(l: T, r: T) -> T:
|
975
|
+
if l is not r:
|
976
|
+
raise ValueError(l, r)
|
977
|
+
return l
|
978
|
+
|
979
|
+
|
980
|
+
def check_is_not(l: T, r: ta.Any) -> T:
|
981
|
+
if l is r:
|
982
|
+
raise ValueError(l, r)
|
983
|
+
return l
|
984
|
+
|
985
|
+
|
986
|
+
def check_in(v: T, c: ta.Container[T]) -> T:
|
987
|
+
if v not in c:
|
988
|
+
raise ValueError(v, c)
|
989
|
+
return v
|
990
|
+
|
991
|
+
|
992
|
+
def check_not_in(v: T, c: ta.Container[T]) -> T:
|
993
|
+
if v in c:
|
994
|
+
raise ValueError(v, c)
|
995
|
+
return v
|
996
|
+
|
997
|
+
|
971
998
|
def check_single(vs: ta.Iterable[T]) -> T:
|
972
999
|
[v] = vs
|
973
1000
|
return v
|
974
1001
|
|
975
1002
|
|
1003
|
+
def check_empty(v: SizedT) -> SizedT:
|
1004
|
+
if len(v):
|
1005
|
+
raise ValueError(v)
|
1006
|
+
return v
|
1007
|
+
|
1008
|
+
|
1009
|
+
def check_non_empty(v: SizedT) -> SizedT:
|
1010
|
+
if not len(v):
|
1011
|
+
raise ValueError(v)
|
1012
|
+
return v
|
1013
|
+
|
1014
|
+
|
976
1015
|
########################################
|
977
1016
|
# ../../../../../omlish/lite/json.py
|
978
1017
|
|
@@ -1730,6 +1769,103 @@ class DelimitingBuffer:
|
|
1730
1769
|
i = p
|
1731
1770
|
|
1732
1771
|
|
1772
|
+
class ReadableListBuffer:
|
1773
|
+
def __init__(self) -> None:
|
1774
|
+
super().__init__()
|
1775
|
+
self._lst: list[bytes] = []
|
1776
|
+
|
1777
|
+
def feed(self, d: bytes) -> None:
|
1778
|
+
if d:
|
1779
|
+
self._lst.append(d)
|
1780
|
+
|
1781
|
+
def _chop(self, i: int, e: int) -> bytes:
|
1782
|
+
lst = self._lst
|
1783
|
+
d = lst[i]
|
1784
|
+
|
1785
|
+
o = b''.join([
|
1786
|
+
*lst[:i],
|
1787
|
+
d[:e],
|
1788
|
+
])
|
1789
|
+
|
1790
|
+
self._lst = [
|
1791
|
+
*([d[e:]] if e < len(d) else []),
|
1792
|
+
*lst[i + 1:],
|
1793
|
+
]
|
1794
|
+
|
1795
|
+
return o
|
1796
|
+
|
1797
|
+
def read(self, n: ta.Optional[int] = None) -> ta.Optional[bytes]:
|
1798
|
+
if n is None:
|
1799
|
+
o = b''.join(self._lst)
|
1800
|
+
self._lst = []
|
1801
|
+
return o
|
1802
|
+
|
1803
|
+
if not (lst := self._lst):
|
1804
|
+
return None
|
1805
|
+
|
1806
|
+
c = 0
|
1807
|
+
for i, d in enumerate(lst):
|
1808
|
+
r = n - c
|
1809
|
+
if (l := len(d)) >= r:
|
1810
|
+
return self._chop(i, r)
|
1811
|
+
c += l
|
1812
|
+
|
1813
|
+
return None
|
1814
|
+
|
1815
|
+
def read_until(self, delim: bytes = b'\n') -> ta.Optional[bytes]:
|
1816
|
+
if not (lst := self._lst):
|
1817
|
+
return None
|
1818
|
+
|
1819
|
+
for i, d in enumerate(lst):
|
1820
|
+
if (p := d.find(delim)) >= 0:
|
1821
|
+
return self._chop(i, p + len(delim))
|
1822
|
+
|
1823
|
+
return None
|
1824
|
+
|
1825
|
+
|
1826
|
+
class IncrementalWriteBuffer:
|
1827
|
+
def __init__(
|
1828
|
+
self,
|
1829
|
+
data: bytes,
|
1830
|
+
*,
|
1831
|
+
write_size: int = 0x10000,
|
1832
|
+
) -> None:
|
1833
|
+
super().__init__()
|
1834
|
+
|
1835
|
+
check_non_empty(data)
|
1836
|
+
self._len = len(data)
|
1837
|
+
self._write_size = write_size
|
1838
|
+
|
1839
|
+
self._lst = [
|
1840
|
+
data[i:i + write_size]
|
1841
|
+
for i in range(0, len(data), write_size)
|
1842
|
+
]
|
1843
|
+
self._pos = 0
|
1844
|
+
|
1845
|
+
@property
|
1846
|
+
def rem(self) -> int:
|
1847
|
+
return self._len - self._pos
|
1848
|
+
|
1849
|
+
def write(self, fn: ta.Callable[[bytes], int]) -> int:
|
1850
|
+
lst = check_non_empty(self._lst)
|
1851
|
+
|
1852
|
+
t = 0
|
1853
|
+
for i, d in enumerate(lst): # noqa
|
1854
|
+
n = fn(check_non_empty(d))
|
1855
|
+
if not n:
|
1856
|
+
break
|
1857
|
+
t += n
|
1858
|
+
|
1859
|
+
if t:
|
1860
|
+
self._lst = [
|
1861
|
+
*([d[n:]] if n < len(d) else []),
|
1862
|
+
*lst[i + 1:],
|
1863
|
+
]
|
1864
|
+
self._pos += t
|
1865
|
+
|
1866
|
+
return t
|
1867
|
+
|
1868
|
+
|
1733
1869
|
########################################
|
1734
1870
|
# ../../../../../omlish/lite/logs.py
|
1735
1871
|
"""
|