omlish 0.0.0.dev461__py3-none-any.whl → 0.0.0.dev462__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.

Potentially problematic release.


This version of omlish might be problematic. Click here for more details.

omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev461'
2
- __revision__ = '7ebd7a07f84e80a8d1855b8a182da756dbb7d6ec'
1
+ __version__ = '0.0.0.dev462'
2
+ __revision__ = '5e5ee1d71115ec07b8f9627222c9f5d6d4016e5a'
3
3
 
4
4
 
5
5
  #
omlish/argparse/all.py CHANGED
@@ -1,17 +1,25 @@
1
1
  # ruff: noqa: I001
2
2
  import argparse
3
3
 
4
- from .cli import ( # noqa
5
- ArgparseArg as Arg,
6
- argparse_arg as arg,
7
- argparse_arg_ as arg_,
4
+ from .. import lang as _lang
8
5
 
9
- ArgparseCmdFn as CmdFn,
10
- ArgparseCmd as Cmd,
11
- argparse_cmd as cmd,
12
6
 
13
- ArgparseCli as Cli,
14
- )
7
+ with _lang.auto_proxy_init(globals()):
8
+ from .cli import ( # noqa
9
+ ArgparseArg as Arg,
10
+ argparse_arg as arg,
11
+ argparse_arg_ as arg_,
12
+
13
+ ArgparseCmdFn as CmdFn,
14
+ ArgparseCmd as Cmd,
15
+ argparse_cmd as cmd,
16
+
17
+ ArgparseCli as Cli,
18
+ )
19
+
20
+ from .utils import ( # noqa
21
+ NoExitArgumentParser,
22
+ )
15
23
 
16
24
 
17
25
  ##
@@ -0,0 +1,21 @@
1
+ import argparse
2
+ import typing as ta
3
+
4
+
5
+ ##
6
+
7
+
8
+ class NoExitArgumentParser(argparse.ArgumentParser):
9
+ def __init__(
10
+ self,
11
+ *args: ta.Any,
12
+ exit_on_error: bool = False,
13
+ **kwargs: ta.Any,
14
+ ) -> None:
15
+ if exit_on_error:
16
+ raise TypeError('exit_on_error=True not supported')
17
+
18
+ super().__init__(*args, exit_on_error=False, **kwargs) # type: ignore[misc]
19
+
20
+ def exit(self, status=0, message=None):
21
+ raise TypeError('NoExitArgumentParser.exit() not supported')
omlish/lang/__init__.py CHANGED
@@ -63,6 +63,9 @@ with _auto_proxy_init(globals(), update_exports=True):
63
63
  snake_case,
64
64
  up_snake_case,
65
65
 
66
+ camel_to_snake,
67
+ snake_to_camel,
68
+
66
69
  get_string_casing,
67
70
  split_string_casing,
68
71
  )
omlish/lang/casing.py CHANGED
@@ -50,6 +50,13 @@ class StringCasing(Abstract):
50
50
 
51
51
  raise NotImplementedError
52
52
 
53
+ #
54
+
55
+ def to(self, other: 'StringCasing') -> ta.Callable[[str], str]:
56
+ def inner(s: str) -> str:
57
+ return other.join(*self.split(s))
58
+ return inner
59
+
53
60
 
54
61
  #
55
62
 
@@ -167,6 +174,10 @@ snake_case = SNAKE_CASE.join
167
174
  up_snake_case = UP_SNAKE_CASE.join
168
175
 
169
176
 
177
+ camel_to_snake = CAMEL_CASE.to(SNAKE_CASE)
178
+ snake_to_camel = SNAKE_CASE.to(CAMEL_CASE)
179
+
180
+
170
181
  ##
171
182
 
172
183
 
omlish/term/alt.py ADDED
@@ -0,0 +1,60 @@
1
+ import io
2
+
3
+
4
+ ##
5
+
6
+
7
+ _ESC = '\x1b'
8
+
9
+
10
+ def _csi(seq: str) -> str:
11
+ return f'{_ESC}[{seq}'
12
+
13
+
14
+ _ENTER_ALT = _csi('?1049h')
15
+ _LEAVE_ALT = _csi('?1049l')
16
+ _HIDE_CURSOR = _csi('?25l')
17
+ _SHOW_CURSOR = _csi('?25h')
18
+ _CLEAR_LINE = _csi('2K')
19
+
20
+ _SYNC_OUTPUT_ON = _csi('?2026h')
21
+ _SYNC_OUTPUT_OFF = _csi('?2026l')
22
+
23
+
24
+ def _move(row: int, col: int) -> str:
25
+ return _csi(f'{row};{col}H') # CUP
26
+
27
+
28
+ _MOVE_BOTTOM_LEFT = _move(999, 1) # clamped
29
+
30
+
31
+ ##
32
+
33
+
34
+ def render_write_from_alt(
35
+ s: str,
36
+ *,
37
+ no_sync_output: bool = False,
38
+ move_and_clear: bool = False,
39
+ ) -> str:
40
+ out = io.StringIO()
41
+
42
+ if not no_sync_output:
43
+ out.write(_SYNC_OUTPUT_ON)
44
+
45
+ out.write(_HIDE_CURSOR)
46
+ out.write(_LEAVE_ALT)
47
+
48
+ if move_and_clear:
49
+ out.write(_MOVE_BOTTOM_LEFT)
50
+ out.write(_CLEAR_LINE)
51
+
52
+ out.write(s)
53
+
54
+ out.write(_ENTER_ALT)
55
+ out.write(_SHOW_CURSOR)
56
+
57
+ if not no_sync_output:
58
+ out.write(_SYNC_OUTPUT_OFF)
59
+
60
+ return out.getvalue()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: omlish
3
- Version: 0.0.0.dev461
3
+ Version: 0.0.0.dev462
4
4
  Summary: omlish
5
5
  Author: wrmsr
6
6
  License-Expression: BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  omlish/.omlish-manifests.json,sha256=FLw7xkPiSXuImZgqSP8BwrEib2R1doSzUPLUkc-QUIA,8410
2
- omlish/__about__.py,sha256=LlWiGEazhGs4KJP-X_qmIvAXOXB4LxUSsqQz07ymSCM,3613
2
+ omlish/__about__.py,sha256=-V3o03Hr1h9gnXTUCGAuhYuAtvBiOS6R2iHHoB5MrB8,3613
3
3
  omlish/__init__.py,sha256=SsyiITTuK0v74XpKV8dqNaCmjOlan1JZKrHQv5rWKPA,253
4
4
  omlish/c3.py,sha256=ZNIMl1kwg3qdei4DiUrJPQe5M81S1e76N-GuNSwLBAE,8683
5
5
  omlish/cached.py,sha256=MLap_p0rdGoDIMVhXVHm1tsbcWobJF0OanoodV03Ju8,542
@@ -16,8 +16,9 @@ omlish/algorithm/distribute.py,sha256=juv6JaCynQG6RaxX0fnNNEVJcvZ8hUS2Mv3ND2t9Y3
16
16
  omlish/algorithm/toposort.py,sha256=5wog_7XTYtg5vq4tcKtn9DcXRsEMaVobzQ6ndMK4HhQ,899
17
17
  omlish/algorithm/unify.py,sha256=jADtgVQkcGKRV4WokG0ePYe9X6BT_8RAS-WSfbBbjUk,838
18
18
  omlish/argparse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- omlish/argparse/all.py,sha256=NeeMM5MIebY7XDAHaCxUzeesEoUYwsf5i9PrBUcO1cI,1057
19
+ omlish/argparse/all.py,sha256=ZQ2jb1eptdDcngyS6ECdTiUdUfoKIev3Z_ej9zQvgIs,1233
20
20
  omlish/argparse/cli.py,sha256=60cfq_WFLwL3YsIQxGAQ7XDi-LzNjH33RavcKdRnhUU,8737
21
+ omlish/argparse/utils.py,sha256=tZAoypACgkTjgOoz7wGWki2TxtRSoGyi0VA6VBElj9k,535
21
22
  omlish/asyncs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
23
  omlish/asyncs/all.py,sha256=zE9zBNepDSczQ-QhnzwFz59IZIex3HuUqfKIgwbJLgY,329
23
24
  omlish/asyncs/buffers.py,sha256=_Ds4Aa1bUWQwQTGmcYsKLjcJ_d5HgbSkPTFrG9y-eMQ,1424
@@ -410,10 +411,10 @@ omlish/iterators/recipes.py,sha256=wOwOZg-zWG9Zc3wcAxJFSe2rtavVBYwZOfG09qYEx_4,4
410
411
  omlish/iterators/tools.py,sha256=M16LXrJhMdsz5ea2qH0vws30ZvhQuQSCVFSLpRf_gTg,2096
411
412
  omlish/iterators/transforms.py,sha256=YHVdD9nBkS1k4kogi4Ba0UOTU_pKkuX9jGw1Tqj3UMw,3598
412
413
  omlish/iterators/unique.py,sha256=BSE-eanva8byFCJi09Nt2zzTsVr8LnTqY1PIInGYRs0,1396
413
- omlish/lang/__init__.py,sha256=cu35SEtPGFFKOrttPsD__wjnefZrue-upqpw01ml50c,10802
414
+ omlish/lang/__init__.py,sha256=qrxPnDUpWIuxUD37cBAOb910CvJ1yX0xWXEQSh5-crY,10851
414
415
  omlish/lang/asyncs.py,sha256=iIHJp7nvgJVj7zS0Ji7NsVSzz54vkzrj0Snc83dxe9g,1965
415
416
  omlish/lang/attrstorage.py,sha256=UUnoENCMQF3twBfxBcIKa5mpXsAxWnNYDayhU8xgmpU,5224
416
- omlish/lang/casing.py,sha256=3_c7cxQOc4z_YezaU2B4NCTAsPh_kDL4wUTK5kZU6kg,4675
417
+ omlish/lang/casing.py,sha256=dmk6gPwfr7Tqp3g2d8d_zZ8ir8TWvXHCEZYl-ECkJS0,4940
417
418
  omlish/lang/clsdct.py,sha256=HAGIvBSbCefzRjXriwYSBLO7QHKRv2UsE78jixOb-fA,1828
418
419
  omlish/lang/collections.py,sha256=kVMp1JJ6ycvKzuiOmf2ZF5Eg2mm3vJGPjkUcV_IACMk,2528
419
420
  omlish/lang/comparison.py,sha256=MOwEG0Yny-jBPHO9kQto9FSRyeNpQW24UABsghkrHxY,1356
@@ -756,6 +757,7 @@ omlish/subprocesses/sync.py,sha256=A4ApwLVJZc8ztT5kYh8O_2i8fq5-7pKH9S3VVxqOCKA,3
756
757
  omlish/subprocesses/utils.py,sha256=v5uEzxmbmRvXwOl_0DtBa5Il6yITKYRgmVSGHcLsT4o,402
757
758
  omlish/subprocesses/wrap.py,sha256=AhGV8rsnaVUMQCFYKkrjj35fs3O-VJLZC1hZ14dz3C8,769
758
759
  omlish/term/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
760
+ omlish/term/alt.py,sha256=To7EfFnqssnMfbrkWzjT_iTGP73P1vbhrHXnCp8_uco,966
759
761
  omlish/term/codes.py,sha256=6_g4wwXP4z9koC9oEW3jSEuw27mQRf43ngD5RA-Qu2s,6390
760
762
  omlish/term/coloring.py,sha256=5lV7E2fyFDixAfm4tM5MFV9vreW5RM94AgUHB9hKaVE,2598
761
763
  omlish/term/confirm.py,sha256=0Qoo-MFBWw26khMMHv92tFXFHNB9GOubfdPLi48KkkY,1054
@@ -826,9 +828,9 @@ omlish/typedvalues/marshal.py,sha256=2xqX6JllhtGpmeYkU7C-qzgU__0x-vd6CzYbAsocQlc
826
828
  omlish/typedvalues/of_.py,sha256=UXkxSj504WI2UrFlqdZJbu2hyDwBhL7XVrc2qdR02GQ,1309
827
829
  omlish/typedvalues/reflect.py,sha256=PAvKW6T4cW7u--iX80w3HWwZUS3SmIZ2_lQjT65uAyk,1026
828
830
  omlish/typedvalues/values.py,sha256=ym46I-q2QJ_6l4UlERqv3yj87R-kp8nCKMRph0xQ3UA,1307
829
- omlish-0.0.0.dev461.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
830
- omlish-0.0.0.dev461.dist-info/METADATA,sha256=77pvoCEFopTc7xv_Ej86VMdyzb88vIfaZA22GkYO16c,19003
831
- omlish-0.0.0.dev461.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
832
- omlish-0.0.0.dev461.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
833
- omlish-0.0.0.dev461.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
834
- omlish-0.0.0.dev461.dist-info/RECORD,,
831
+ omlish-0.0.0.dev462.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
832
+ omlish-0.0.0.dev462.dist-info/METADATA,sha256=cz6Ceh1xL9eOzPJiUFmjYRw1SA220Ujydbg5IBx-ufs,19003
833
+ omlish-0.0.0.dev462.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
834
+ omlish-0.0.0.dev462.dist-info/entry_points.txt,sha256=Lt84WvRZJskWCAS7xnQGZIeVWksprtUHj0llrvVmod8,35
835
+ omlish-0.0.0.dev462.dist-info/top_level.txt,sha256=pePsKdLu7DvtUiecdYXJ78iO80uDNmBlqe-8hOzOmfs,7
836
+ omlish-0.0.0.dev462.dist-info/RECORD,,