omlish 0.0.0.dev77__py3-none-any.whl → 0.0.0.dev79__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/diag/_pycharm/runhack.py +23 -16
- omlish/lite/check.py +17 -0
- omlish/{io.py → lite/io.py} +36 -51
- omlish/lite/strings.py +14 -2
- {omlish-0.0.0.dev77.dist-info → omlish-0.0.0.dev79.dist-info}/METADATA +1 -1
- {omlish-0.0.0.dev77.dist-info → omlish-0.0.0.dev79.dist-info}/RECORD +11 -11
- {omlish-0.0.0.dev77.dist-info → omlish-0.0.0.dev79.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev77.dist-info → omlish-0.0.0.dev79.dist-info}/WHEEL +0 -0
- {omlish-0.0.0.dev77.dist-info → omlish-0.0.0.dev79.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev77.dist-info → omlish-0.0.0.dev79.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
omlish/diag/_pycharm/runhack.py
CHANGED
@@ -1190,6 +1190,18 @@ class HackRunner:
|
|
1190
1190
|
self._is_debug = is_debug
|
1191
1191
|
self._is_enabled = is_enabled
|
1192
1192
|
|
1193
|
+
@_cached_nullary
|
1194
|
+
def _debug_formatter(self):
|
1195
|
+
try:
|
1196
|
+
import pprint # noqa
|
1197
|
+
except ImportError:
|
1198
|
+
return repr
|
1199
|
+
|
1200
|
+
def df(arg):
|
1201
|
+
return pprint.pformat(arg, sort_dicts=False)
|
1202
|
+
|
1203
|
+
return df
|
1204
|
+
|
1193
1205
|
def _debug(self, arg):
|
1194
1206
|
if not self._is_debug:
|
1195
1207
|
return
|
@@ -1197,12 +1209,7 @@ class HackRunner:
|
|
1197
1209
|
if isinstance(arg, str):
|
1198
1210
|
s = arg
|
1199
1211
|
else:
|
1200
|
-
|
1201
|
-
import pprint # noqa
|
1202
|
-
except ImportError:
|
1203
|
-
s = repr(arg)
|
1204
|
-
else:
|
1205
|
-
s = pprint.pformat(arg, sort_dicts=False)
|
1212
|
+
s = self._debug_formatter()(arg)
|
1206
1213
|
|
1207
1214
|
print(f'{_DEBUG_PREFIX}: {s}', file=sys.stderr)
|
1208
1215
|
|
@@ -1343,23 +1350,23 @@ def _install_pth_file(
|
|
1343
1350
|
) -> bool:
|
1344
1351
|
import site
|
1345
1352
|
lib_dir = site.getsitepackages()[0]
|
1346
|
-
verbose and print(f'{lib_dir=}')
|
1353
|
+
verbose and print(f'{lib_dir=}', file=sys.stderr)
|
1347
1354
|
|
1348
1355
|
pth_file = os.path.join(lib_dir, file_name)
|
1349
|
-
verbose and print(f'{pth_file=}')
|
1356
|
+
verbose and print(f'{pth_file=}', file=sys.stderr)
|
1350
1357
|
if not force and os.path.isfile(pth_file):
|
1351
|
-
verbose and print('pth_file exists, exiting')
|
1358
|
+
verbose and print('pth_file exists, exiting', file=sys.stderr)
|
1352
1359
|
return False
|
1353
1360
|
|
1354
1361
|
if not editable:
|
1355
1362
|
if module_name is None:
|
1356
1363
|
module_name = '_' + file_name.removesuffix('.pth').replace('-', '_')
|
1357
|
-
verbose and print(f'{module_name=}')
|
1364
|
+
verbose and print(f'{module_name=}', file=sys.stderr)
|
1358
1365
|
|
1359
1366
|
mod_file = os.path.join(lib_dir, module_name + '.py')
|
1360
|
-
verbose and print(f'{mod_file=}')
|
1367
|
+
verbose and print(f'{mod_file=}', file=sys.stderr)
|
1361
1368
|
if not force and os.path.isfile(mod_file):
|
1362
|
-
verbose and print('mod_file exists, exiting')
|
1369
|
+
verbose and print('mod_file exists, exiting', file=sys.stderr)
|
1363
1370
|
return False
|
1364
1371
|
|
1365
1372
|
import inspect
|
@@ -1368,20 +1375,20 @@ def _install_pth_file(
|
|
1368
1375
|
else:
|
1369
1376
|
if module_name is None:
|
1370
1377
|
module_name = __package__ + '.runhack'
|
1371
|
-
verbose and print(f'{module_name=}')
|
1378
|
+
verbose and print(f'{module_name=}', file=sys.stderr)
|
1372
1379
|
|
1373
1380
|
mod_file = mod_src = None # type: ignore
|
1374
1381
|
|
1375
1382
|
pth_src = _build_pth_file_src(module_name)
|
1376
|
-
verbose and print(f'{pth_src=}')
|
1383
|
+
verbose and print(f'{pth_src=}', file=sys.stderr)
|
1377
1384
|
|
1378
1385
|
if not dry_run:
|
1379
1386
|
if mod_file is not None:
|
1380
|
-
verbose and print(f'writing {mod_file}')
|
1387
|
+
verbose and print(f'writing {mod_file}', file=sys.stderr)
|
1381
1388
|
with open(mod_file, 'w') as f:
|
1382
1389
|
f.write(mod_src) # type: ignore
|
1383
1390
|
|
1384
|
-
verbose and print(f'writing {pth_file}')
|
1391
|
+
verbose and print(f'writing {pth_file}', file=sys.stderr)
|
1385
1392
|
with open(pth_file, 'w') as f:
|
1386
1393
|
f.write(pth_src)
|
1387
1394
|
|
omlish/lite/check.py
CHANGED
@@ -38,3 +38,20 @@ def check_non_empty_str(v: ta.Optional[str]) -> str:
|
|
38
38
|
def check_state(v: bool, msg: str = 'Illegal state') -> None:
|
39
39
|
if not v:
|
40
40
|
raise ValueError(msg)
|
41
|
+
|
42
|
+
|
43
|
+
def check_equal(l: T, r: T) -> T:
|
44
|
+
if l != r:
|
45
|
+
raise ValueError(l, r)
|
46
|
+
return l
|
47
|
+
|
48
|
+
|
49
|
+
def check_not_equal(l: T, r: T) -> T:
|
50
|
+
if l == r:
|
51
|
+
raise ValueError(l, r)
|
52
|
+
return l
|
53
|
+
|
54
|
+
|
55
|
+
def check_single(vs: ta.Iterable[T]) -> T:
|
56
|
+
[v] = vs
|
57
|
+
return v
|
omlish/{io.py → lite/io.py}
RENAMED
@@ -1,31 +1,31 @@
|
|
1
|
-
|
1
|
+
# ruff: noqa: UP007
|
2
2
|
import io
|
3
3
|
import typing as ta
|
4
4
|
|
5
|
-
from . import
|
5
|
+
from .check import check_isinstance
|
6
|
+
from .check import check_not_none
|
7
|
+
from .strings import attr_repr
|
6
8
|
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
class ClosedDelimitingBufferError(DelimitingBufferError):
|
14
|
-
pass
|
10
|
+
class DelimitingBuffer:
|
11
|
+
"""
|
12
|
+
https://github.com/python-trio/trio/issues/796 :|
|
13
|
+
"""
|
15
14
|
|
15
|
+
#
|
16
16
|
|
17
|
-
class
|
18
|
-
|
17
|
+
class Error(Exception):
|
18
|
+
def __init__(self, buffer: 'DelimitingBuffer') -> None:
|
19
|
+
super().__init__(buffer)
|
20
|
+
self.buffer = buffer
|
19
21
|
|
22
|
+
def __repr__(self) -> str:
|
23
|
+
return attr_repr(self, 'buffer')
|
20
24
|
|
21
|
-
class
|
22
|
-
|
25
|
+
class ClosedError(Error):
|
26
|
+
pass
|
23
27
|
|
24
|
-
|
25
|
-
class DelimitingBuffer:
|
26
|
-
"""
|
27
|
-
https://github.com/python-trio/trio/issues/796 :|
|
28
|
-
"""
|
28
|
+
#
|
29
29
|
|
30
30
|
DEFAULT_DELIMITERS: bytes = b'\n'
|
31
31
|
|
@@ -34,19 +34,17 @@ class DelimitingBuffer:
|
|
34
34
|
delimiters: ta.Iterable[int] = DEFAULT_DELIMITERS,
|
35
35
|
*,
|
36
36
|
keep_ends: bool = False,
|
37
|
-
max_size: int
|
38
|
-
on_full: ta.Literal['raise', 'yield'] = 'raise',
|
39
|
-
on_incomplete: ta.Literal['raise', 'yield'] = 'yield',
|
37
|
+
max_size: ta.Optional[int] = None,
|
40
38
|
) -> None:
|
41
39
|
super().__init__()
|
42
40
|
|
43
|
-
self._delimiters = frozenset(
|
41
|
+
self._delimiters = frozenset(check_isinstance(d, int) for d in delimiters)
|
44
42
|
self._keep_ends = keep_ends
|
45
43
|
self._max_size = max_size
|
46
|
-
self._on_full = on_full
|
47
|
-
self._on_incomplete = on_incomplete
|
48
44
|
|
49
|
-
self._buf: io.BytesIO
|
45
|
+
self._buf: ta.Optional[io.BytesIO] = io.BytesIO()
|
46
|
+
|
47
|
+
#
|
50
48
|
|
51
49
|
@property
|
52
50
|
def is_closed(self) -> bool:
|
@@ -54,15 +52,15 @@ class DelimitingBuffer:
|
|
54
52
|
|
55
53
|
def tell(self) -> int:
|
56
54
|
if (buf := self._buf) is None:
|
57
|
-
raise
|
55
|
+
raise self.ClosedError(self)
|
58
56
|
return buf.tell()
|
59
57
|
|
60
58
|
def peek(self) -> bytes:
|
61
59
|
if (buf := self._buf) is None:
|
62
|
-
raise
|
60
|
+
raise self.ClosedError(self)
|
63
61
|
return buf.getvalue()
|
64
62
|
|
65
|
-
def _find_delim(self, data: bytes
|
63
|
+
def _find_delim(self, data: ta.Union[bytes, bytearray], i: int) -> ta.Optional[int]:
|
66
64
|
r = None # type: int | None
|
67
65
|
for d in self._delimiters:
|
68
66
|
if (p := data.find(d, i)) >= 0:
|
@@ -71,7 +69,7 @@ class DelimitingBuffer:
|
|
71
69
|
return r
|
72
70
|
|
73
71
|
def _append_and_reset(self, chunk: bytes) -> bytes:
|
74
|
-
buf =
|
72
|
+
buf = check_not_none(self._buf)
|
75
73
|
if not buf.tell():
|
76
74
|
return chunk
|
77
75
|
|
@@ -80,22 +78,18 @@ class DelimitingBuffer:
|
|
80
78
|
buf.seek(0)
|
81
79
|
return ret
|
82
80
|
|
83
|
-
|
81
|
+
class Incomplete(ta.NamedTuple):
|
82
|
+
b: bytes
|
83
|
+
|
84
|
+
def feed(self, data: ta.Union[bytes, bytearray]) -> ta.Generator[ta.Union[bytes, Incomplete], None, None]:
|
84
85
|
if (buf := self._buf) is None:
|
85
|
-
raise
|
86
|
+
raise self.ClosedError(self)
|
86
87
|
|
87
88
|
if not data:
|
88
89
|
self._buf = None
|
89
90
|
|
90
91
|
if buf.tell():
|
91
|
-
|
92
|
-
raise IncompleteDelimitingBufferError(self)
|
93
|
-
|
94
|
-
elif self._on_incomplete == 'yield':
|
95
|
-
yield buf.getvalue()
|
96
|
-
|
97
|
-
else:
|
98
|
-
raise ValueError(f'Unknown on_incomplete value: {self._on_incomplete!r}')
|
92
|
+
yield self.Incomplete(buf.getvalue())
|
99
93
|
|
100
94
|
return
|
101
95
|
|
@@ -128,15 +122,6 @@ class DelimitingBuffer:
|
|
128
122
|
buf.write(data[i:])
|
129
123
|
return
|
130
124
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
elif self._on_full == 'yield':
|
135
|
-
p = i + remaining_buf_capacity
|
136
|
-
|
137
|
-
yield self._append_and_reset(data[i:p])
|
138
|
-
|
139
|
-
i = p
|
140
|
-
|
141
|
-
else:
|
142
|
-
raise ValueError(f'Unknown on_full value: {self._on_full!r}')
|
125
|
+
p = i + remaining_buf_capacity
|
126
|
+
yield self.Incomplete(self._append_and_reset(data[i:p]))
|
127
|
+
i = p
|
omlish/lite/strings.py
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import typing as ta
|
2
|
+
|
3
|
+
|
4
|
+
def camel_case(name: str, lower: bool = False) -> str:
|
5
|
+
if not name:
|
6
|
+
return ''
|
7
|
+
s = ''.join(map(str.capitalize, name.split('_'))) # noqa
|
8
|
+
if lower:
|
9
|
+
s = s[0].lower() + s[1:]
|
10
|
+
return s
|
3
11
|
|
4
12
|
|
5
13
|
def snake_case(name: str) -> str:
|
@@ -23,3 +31,7 @@ def is_sunder(name: str) -> bool:
|
|
23
31
|
name[-2:-1] != '_' and
|
24
32
|
len(name) > 2
|
25
33
|
)
|
34
|
+
|
35
|
+
|
36
|
+
def attr_repr(obj: ta.Any, *attrs: str) -> str:
|
37
|
+
return f'{type(obj).__name__}({", ".join(f"{attr}={getattr(obj, attr)!r}" for attr in attrs)})'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
omlish/.manifests.json,sha256=ucaSu1XcJPryi-AqINUejkVDeJAFk7Bp5ar5_tJTgME,1692
|
2
|
-
omlish/__about__.py,sha256=
|
2
|
+
omlish/__about__.py,sha256=n67KU5dW8P8-g8wxFQr62vt3nYPKPIbVpfimN-TyI-8,3420
|
3
3
|
omlish/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
omlish/argparse.py,sha256=Dc73G8lyoQBLvXhMYUbzQUh4SJu_OTvKUXjSUxq_ang,7499
|
5
5
|
omlish/c3.py,sha256=4vogWgwPb8TbNS2KkZxpoWbwjj7MuHG2lQG-hdtkvjI,8062
|
@@ -11,7 +11,6 @@ omlish/dynamic.py,sha256=35C_cCX_Vq2HrHzGk5T-zbrMvmUdiIiwDzDNixczoDo,6541
|
|
11
11
|
omlish/fnpairs.py,sha256=Sl8CMFNyDS-1JYAjSWqnT5FmUm9Lj6o7FxSRo7g4jww,10875
|
12
12
|
omlish/fnpipes.py,sha256=AJkgz9nvRRm7oqw7ZgYyz21klu276LWi54oYCLg-vOg,2196
|
13
13
|
omlish/genmachine.py,sha256=LCMiqvK32dAWtrlB6lKw9tXdQFiXC8rRdk4TMQYIroU,1603
|
14
|
-
omlish/io.py,sha256=4_0naIRniQ_xGhCW44xkk3sKqgddCbtIjbs72SGqK9g,3679
|
15
14
|
omlish/iterators.py,sha256=GGLC7RIT86uXMjhIIIqnff_Iu5SI_b9rXYywYGFyzmo,7292
|
16
15
|
omlish/libc.py,sha256=8r7Ejyhttk9ruCfBkxNTrlzir5WPbDE2vmY7VPlceMA,15362
|
17
16
|
omlish/matchfns.py,sha256=I1IlQGfEyk_AcFSy6ulVS3utC-uwyZM2YfUXYHc9Bw0,6152
|
@@ -159,7 +158,7 @@ omlish/diag/ps.py,sha256=1JWxZen3fVG-20R6ZZ8BtO_gpzw_5bhHZiKdoHkgxoU,1004
|
|
159
158
|
omlish/diag/pydevd.py,sha256=Fsx9rfCOnwLD6RLBqH0uAdtq75rbNeBAQfiDvIBd3e0,7295
|
160
159
|
omlish/diag/threads.py,sha256=1-x02VCDZ407gfbtXm1pWK-ubqhqfePm9PMqkHCVoqk,3642
|
161
160
|
omlish/diag/_pycharm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
162
|
-
omlish/diag/_pycharm/runhack.py,sha256=
|
161
|
+
omlish/diag/_pycharm/runhack.py,sha256=eJlaUXIcFzAjOop_793RwNS_KF9NmhLv0i22xRVVeo0,34951
|
163
162
|
omlish/diag/pycharm/__init__.py,sha256=sT-ub7flKeCCbM_i32z9-eGV8hgGJ45hwdcqtGDkVRY,153
|
164
163
|
omlish/diag/pycharm/cli.py,sha256=7SRh6yj8S5YGda4bq9BD4Kzwtgg4_Wa-K202ReZN2iI,1011
|
165
164
|
omlish/diag/pycharm/pycharm.py,sha256=g-IfF8FBH93o6k_KDrLy8kIiFSLe3n39I2URipfFy0Q,3115
|
@@ -278,15 +277,16 @@ omlish/lifecycles/states.py,sha256=zqMOU2ZU-MDNnWuwauM3_anIAiXM8LoBDElDEraptFg,1
|
|
278
277
|
omlish/lifecycles/transitions.py,sha256=qQtFby-h4VzbvgaUqT2NnbNumlcOx9FVVADP9t83xj4,1939
|
279
278
|
omlish/lite/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
280
279
|
omlish/lite/cached.py,sha256=dUm647FbIsoxWT23XUFM51F7i-C2Buxr5b5zzgbCtQI,546
|
281
|
-
omlish/lite/check.py,sha256=
|
280
|
+
omlish/lite/check.py,sha256=ouJme9tkzWXKymm_xZDK4mngdYSkxDrok6CSegvf-1w,1015
|
282
281
|
omlish/lite/contextmanagers.py,sha256=HnQJiyrOmSvTL22XRJrFl5CLpCyHD9fsntEUAr9G-60,427
|
282
|
+
omlish/lite/io.py,sha256=6qixpFyLwCVRi44Np49xknvwZEtCz1yYMgsawE_Gh0Y,3125
|
283
283
|
omlish/lite/json.py,sha256=7-02Ny4fq-6YAu5ynvqoijhuYXWpLmfCI19GUeZnb1c,740
|
284
284
|
omlish/lite/logs.py,sha256=vkFkSX0Izb2P-NNMqqNLSec0BzeLOtHoQWgdXwQuDPU,6007
|
285
285
|
omlish/lite/marshal.py,sha256=kZtfIiFfmxEi8ZKne3fT0R8g8kLmJ-Q5nq4kOvwhiqk,8656
|
286
286
|
omlish/lite/reflect.py,sha256=9QYJwdINraq1JNMEgvoqeSlVvRRgOXpxAkpgX8EgRXc,1307
|
287
287
|
omlish/lite/runtime.py,sha256=VUhmNQvwf8QzkWSKj4Q0ReieJA_PzHaJNRBivfTseow,452
|
288
288
|
omlish/lite/secrets.py,sha256=3Mz3V2jf__XU9qNHcH56sBSw95L3U2UPL24bjvobG0c,816
|
289
|
-
omlish/lite/strings.py,sha256=
|
289
|
+
omlish/lite/strings.py,sha256=GFkkp-q6sgO06EACyp33oiyCQQKAbpGMnVMFHZE5KP8,955
|
290
290
|
omlish/lite/subprocesses.py,sha256=KuGV3ImehMjCUK0JoV3pUtG_7o5wei1lRDn9HxzByAg,3063
|
291
291
|
omlish/logs/__init__.py,sha256=FbOyAW-lGH8gyBlSVArwljdYAU6RnwZLI5LwAfuNnrk,438
|
292
292
|
omlish/logs/_abc.py,sha256=UgrCUQVUi_PvT3p1CEkb3P74CFrFcZq2AFby3GEUv9M,5974
|
@@ -439,9 +439,9 @@ omlish/text/delimit.py,sha256=ubPXcXQmtbOVrUsNh5gH1mDq5H-n1y2R4cPL5_DQf68,4928
|
|
439
439
|
omlish/text/glyphsplit.py,sha256=Ug-dPRO7x-OrNNr8g1y6DotSZ2KH0S-VcOmUobwa4B0,3296
|
440
440
|
omlish/text/indent.py,sha256=6Jj6TFY9unaPa4xPzrnZemJ-fHsV53IamP93XGjSUHs,1274
|
441
441
|
omlish/text/parts.py,sha256=7vPF1aTZdvLVYJ4EwBZVzRSy8XB3YqPd7JwEnNGGAOo,6495
|
442
|
-
omlish-0.0.0.
|
443
|
-
omlish-0.0.0.
|
444
|
-
omlish-0.0.0.
|
445
|
-
omlish-0.0.0.
|
446
|
-
omlish-0.0.0.
|
447
|
-
omlish-0.0.0.
|
442
|
+
omlish-0.0.0.dev79.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
443
|
+
omlish-0.0.0.dev79.dist-info/METADATA,sha256=5K_85mTbTv1R0YAK2OfCJr2ClIg0_uqVi2_d0EriK88,4167
|
444
|
+
omlish-0.0.0.dev79.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
445
|
+
omlish-0.0.0.dev79.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
|
446
|
+
omlish-0.0.0.dev79.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
|
447
|
+
omlish-0.0.0.dev79.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|