kdcube-cli 0.0.0__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.
- kdcube_cli/__init__.py +1 -0
- kdcube_cli/banner.py +476 -0
- kdcube_cli/cli.py +5468 -0
- kdcube_cli/export_live_bundles.py +500 -0
- kdcube_cli/frontend_config.py +387 -0
- kdcube_cli/installer.py +4959 -0
- kdcube_cli/tty_keys.py +74 -0
- kdcube_cli-0.0.0.dist-info/METADATA +5 -0
- kdcube_cli-0.0.0.dist-info/RECORD +12 -0
- kdcube_cli-0.0.0.dist-info/WHEEL +5 -0
- kdcube_cli-0.0.0.dist-info/licenses/LICENSE +21 -0
- kdcube_cli-0.0.0.dist-info/top_level.txt +1 -0
kdcube_cli/tty_keys.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import select
|
|
5
|
+
import sys
|
|
6
|
+
import termios
|
|
7
|
+
import tty
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
KEY_UP = "__UP__"
|
|
11
|
+
KEY_DOWN = "__DOWN__"
|
|
12
|
+
KEY_ENTER = "__ENTER__"
|
|
13
|
+
KEY_ESCAPE = "__ESCAPE__"
|
|
14
|
+
KEY_INTERRUPT = "__INTERRUPT__"
|
|
15
|
+
KEY_EOF = "__EOF__"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def read_tty_key() -> str:
|
|
19
|
+
fd: int | None = None
|
|
20
|
+
owns_fd = False
|
|
21
|
+
old_attrs = None
|
|
22
|
+
try:
|
|
23
|
+
try:
|
|
24
|
+
fd = os.open("/dev/tty", os.O_RDONLY)
|
|
25
|
+
owns_fd = True
|
|
26
|
+
except OSError:
|
|
27
|
+
fd = sys.stdin.fileno()
|
|
28
|
+
|
|
29
|
+
old_attrs = termios.tcgetattr(fd)
|
|
30
|
+
tty.setraw(fd)
|
|
31
|
+
|
|
32
|
+
first = os.read(fd, 1)
|
|
33
|
+
if not first:
|
|
34
|
+
return KEY_EOF
|
|
35
|
+
if first == b"\x03":
|
|
36
|
+
return KEY_INTERRUPT
|
|
37
|
+
if first in {b"\r", b"\n"}:
|
|
38
|
+
return KEY_ENTER
|
|
39
|
+
if first != b"\x1b":
|
|
40
|
+
return first.decode("utf-8", errors="ignore")
|
|
41
|
+
|
|
42
|
+
seq = bytearray(first)
|
|
43
|
+
while True:
|
|
44
|
+
ready, _, _ = select.select([fd], [], [], 0.03)
|
|
45
|
+
if not ready:
|
|
46
|
+
break
|
|
47
|
+
chunk = os.read(fd, 1)
|
|
48
|
+
if not chunk:
|
|
49
|
+
break
|
|
50
|
+
seq.extend(chunk)
|
|
51
|
+
if bytes(seq) in {b"\x1b[A", b"\x1b[B", b"\x1bOA", b"\x1bOB", b"\x1bk", b"\x1bj"}:
|
|
52
|
+
break
|
|
53
|
+
if len(seq) >= 3 and seq[:2] == b"\x1b[" and seq[-1:] in b"~ABCDHF":
|
|
54
|
+
break
|
|
55
|
+
|
|
56
|
+
raw = bytes(seq)
|
|
57
|
+
if raw in {b"\x1b[A", b"\x1bOA"}:
|
|
58
|
+
return KEY_UP
|
|
59
|
+
if raw in {b"\x1b[B", b"\x1bOB"}:
|
|
60
|
+
return KEY_DOWN
|
|
61
|
+
if raw == b"\x1b":
|
|
62
|
+
return KEY_ESCAPE
|
|
63
|
+
return raw.decode("utf-8", errors="ignore")
|
|
64
|
+
finally:
|
|
65
|
+
if fd is not None and old_attrs is not None:
|
|
66
|
+
try:
|
|
67
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, old_attrs)
|
|
68
|
+
except Exception:
|
|
69
|
+
pass
|
|
70
|
+
if owns_fd and fd is not None:
|
|
71
|
+
try:
|
|
72
|
+
os.close(fd)
|
|
73
|
+
except Exception:
|
|
74
|
+
pass
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
kdcube_cli/__init__.py,sha256=W-Iw-hOna0MxXOaE4ehJxxBNt6owr2n32RFEtLZl4tM,31
|
|
2
|
+
kdcube_cli/banner.py,sha256=uNnEfBpXzyjHksC_cZFzjHl9sClW7wV1kDRY1Uac90g,17349
|
|
3
|
+
kdcube_cli/cli.py,sha256=NyDfAmivm2fPlUrw15Kw697suAEV_-bkNNWq4tD1Xoc,232011
|
|
4
|
+
kdcube_cli/export_live_bundles.py,sha256=p2XnyhLAwr4wQWnv_VaYWgtQA2NRBiKdB4qTTohUsQI,17267
|
|
5
|
+
kdcube_cli/frontend_config.py,sha256=r1wGBqPNp_NnQbv8UDG95eVhEMv22zS9FtwxNWghXck,14843
|
|
6
|
+
kdcube_cli/installer.py,sha256=3nxfai8DJ0BBCyCTcVsnVxuP9r9WskZ2hKUUGr6a4Kw,218465
|
|
7
|
+
kdcube_cli/tty_keys.py,sha256=mVxo4FS6RrqJLSr1_u-mhymWbKnbbYMaoaICTjflJoQ,1961
|
|
8
|
+
kdcube_cli-0.0.0.dist-info/licenses/LICENSE,sha256=PeMtjU0gdVu4V_0-x-RlO-lONFpC0_UkzF811-60nHM,1068
|
|
9
|
+
kdcube_cli-0.0.0.dist-info/METADATA,sha256=032VeQMX2D1IhPagK4lkYhWKw3z_bpLYmRcAle9qv3k,98
|
|
10
|
+
kdcube_cli-0.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
11
|
+
kdcube_cli-0.0.0.dist-info/top_level.txt,sha256=3IbvB9Y6xeVsD8Hkd8zemQ3dL3kae58MTKK3RY_np5U,11
|
|
12
|
+
kdcube_cli-0.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Elena Viter
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
kdcube_cli
|