replbase 0.0.15__tar.gz → 0.0.16__tar.gz
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.
- {replbase-0.0.15 → replbase-0.0.16}/PKG-INFO +1 -1
- {replbase-0.0.15 → replbase-0.0.16}/pyproject.toml +1 -1
- {replbase-0.0.15 → replbase-0.0.16}/replbase/repl_base.py +21 -1
- {replbase-0.0.15 → replbase-0.0.16}/LICENSE +0 -0
- {replbase-0.0.15 → replbase-0.0.16}/README.md +0 -0
- {replbase-0.0.15 → replbase-0.0.16}/replbase/__init__.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "replbase"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.16"
|
|
8
8
|
description = "\"Combination of other REPL tools into a reusable class that generates a REPL\""
|
|
9
9
|
authors = [ "Joseph Bochinski <stirgejr@gmail.com>",]
|
|
10
10
|
license = "MIT"
|
|
@@ -20,7 +20,7 @@ import re
|
|
|
20
20
|
import shlex
|
|
21
21
|
|
|
22
22
|
from dataclasses import dataclass, field
|
|
23
|
-
from typing import Callable, Literal
|
|
23
|
+
from typing import Any, Callable, Literal
|
|
24
24
|
|
|
25
25
|
from prompt_toolkit import PromptSession
|
|
26
26
|
from prompt_toolkit.history import FileHistory
|
|
@@ -222,6 +222,26 @@ class ReplBase:
|
|
|
222
222
|
if choice and choice > 0 and choice <= len(choices):
|
|
223
223
|
return choices[choice - 1]
|
|
224
224
|
|
|
225
|
+
def input_choice_dict(self, prompt: str, choices: dict) -> Any:
|
|
226
|
+
"""Similar to input_choice, but with more control over the options
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
prompt (str): String to print to the user
|
|
230
|
+
choices (dict): Dict of choices; keys will be the displayed options, values will be the associated return value
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
Any: Selected value
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
keys = list(choices.keys())
|
|
237
|
+
for idx, choice in enumerate(keys):
|
|
238
|
+
self.print(f"[{idx+1}]: {choice}")
|
|
239
|
+
|
|
240
|
+
choice = self.input_int(prompt)
|
|
241
|
+
if choice and choice > 0 and choice <= len(keys):
|
|
242
|
+
key = keys[choice]
|
|
243
|
+
return choices[key]
|
|
244
|
+
|
|
225
245
|
def debug(self, *args) -> None:
|
|
226
246
|
"""Print only if debug_enabled == True"""
|
|
227
247
|
if self.debug_enabled:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|