omdev 0.0.0.dev457__py3-none-any.whl → 0.0.0.dev459__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.
- omdev/.omlish-manifests.json +15 -27
- omdev/__about__.py +5 -4
- omdev/tui/apps/__init__.py +0 -0
- omdev/tui/apps/markdown/__init__.py +0 -0
- omdev/tui/apps/markdown/__main__.py +11 -0
- omdev/{ptk → tui/apps}/markdown/cli.py +6 -7
- {omdev-0.0.0.dev457.dist-info → omdev-0.0.0.dev459.dist-info}/METADATA +7 -5
- {omdev-0.0.0.dev457.dist-info → omdev-0.0.0.dev459.dist-info}/RECORD +13 -22
- omdev/ptk/__init__.py +0 -104
- omdev/ptk/apps/ncdu.py +0 -167
- omdev/ptk/markdown/LICENSE +0 -22
- omdev/ptk/markdown/__init__.py +0 -10
- omdev/ptk/markdown/__main__.py +0 -11
- omdev/ptk/markdown/border.py +0 -94
- omdev/ptk/markdown/markdown.py +0 -390
- omdev/ptk/markdown/parser.py +0 -42
- omdev/ptk/markdown/styles.py +0 -29
- omdev/ptk/markdown/tags.py +0 -299
- omdev/ptk/markdown/utils.py +0 -366
- omdev/ptk/prompts.py +0 -68
- /omdev/{ptk/apps → tui}/__init__.py +0 -0
- {omdev-0.0.0.dev457.dist-info → omdev-0.0.0.dev459.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev457.dist-info → omdev-0.0.0.dev459.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev457.dist-info → omdev-0.0.0.dev459.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev457.dist-info → omdev-0.0.0.dev459.dist-info}/top_level.txt +0 -0
omdev/ptk/prompts.py
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
import typing as ta
|
2
|
-
|
3
|
-
from prompt_toolkit.formatted_text import merge_formatted_text
|
4
|
-
from prompt_toolkit.key_binding import KeyBindings
|
5
|
-
from prompt_toolkit.key_binding import KeyPressEvent
|
6
|
-
from prompt_toolkit.shortcuts import PromptSession
|
7
|
-
|
8
|
-
from omlish import check
|
9
|
-
from omlish import lang
|
10
|
-
|
11
|
-
|
12
|
-
##
|
13
|
-
|
14
|
-
|
15
|
-
async def session_prompt(session, *args, **kwargs):
|
16
|
-
return await lang.make_maysync(session.prompt, ta.cast(ta.Any, session.prompt_async))(*args, **kwargs)
|
17
|
-
|
18
|
-
|
19
|
-
async def prompt(*args, **kwargs):
|
20
|
-
return await session_prompt(PromptSession(), *args, **kwargs)
|
21
|
-
|
22
|
-
|
23
|
-
##
|
24
|
-
|
25
|
-
|
26
|
-
def create_strict_confirm_session(
|
27
|
-
message: str,
|
28
|
-
suffix: str = ' (y/n) ',
|
29
|
-
) -> PromptSession[str | bool]:
|
30
|
-
"""Create a `PromptSession` object for the 'confirm' function."""
|
31
|
-
|
32
|
-
bindings = KeyBindings()
|
33
|
-
|
34
|
-
@bindings.add('y')
|
35
|
-
@bindings.add('Y')
|
36
|
-
def yes(event: KeyPressEvent) -> None:
|
37
|
-
session.default_buffer.text = 'y'
|
38
|
-
event.app.exit(result=True)
|
39
|
-
|
40
|
-
@bindings.add('n')
|
41
|
-
@bindings.add('N')
|
42
|
-
def no(event: KeyPressEvent) -> None:
|
43
|
-
session.default_buffer.text = 'n'
|
44
|
-
event.app.exit(result=False)
|
45
|
-
|
46
|
-
complete_message = merge_formatted_text([message, suffix])
|
47
|
-
session: PromptSession[str | bool] = PromptSession(
|
48
|
-
complete_message,
|
49
|
-
key_bindings=bindings,
|
50
|
-
)
|
51
|
-
return session
|
52
|
-
|
53
|
-
|
54
|
-
async def strict_confirm(message: str = 'Confirm?', suffix: str = ' (y/n) ') -> bool:
|
55
|
-
"""Display a confirmation prompt that returns True/False. Requires an explicit answer."""
|
56
|
-
|
57
|
-
while True:
|
58
|
-
session = create_strict_confirm_session(message, suffix)
|
59
|
-
ret = await lang.make_maysync(session.prompt, ta.cast(ta.Any, session.prompt_async))()
|
60
|
-
|
61
|
-
if isinstance(ret, str):
|
62
|
-
check.empty(ret)
|
63
|
-
|
64
|
-
elif isinstance(ret, bool):
|
65
|
-
return ret
|
66
|
-
|
67
|
-
else:
|
68
|
-
raise TypeError(ret)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|