replbase 0.0.6__tar.gz → 0.0.7__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.6 → replbase-0.0.7}/PKG-INFO +1 -1
- {replbase-0.0.6 → replbase-0.0.7}/pyproject.toml +1 -1
- {replbase-0.0.6 → replbase-0.0.7}/replbase/repl_base.py +20 -0
- {replbase-0.0.6 → replbase-0.0.7}/LICENSE +0 -0
- {replbase-0.0.6 → replbase-0.0.7}/README.md +0 -0
- {replbase-0.0.6 → replbase-0.0.7}/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.7"
|
|
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"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import argparse
|
|
17
17
|
import os
|
|
18
|
+
import re
|
|
18
19
|
import shlex
|
|
19
20
|
|
|
20
21
|
from dataclasses import dataclass, field
|
|
@@ -39,6 +40,10 @@ ColorSystem = Literal["auto", "standard", "256", "truecolor", "windows"]
|
|
|
39
40
|
# region Classes
|
|
40
41
|
|
|
41
42
|
|
|
43
|
+
def is_num_str(val: str) -> bool:
|
|
44
|
+
return bool(re.match(r"^-?\d+(\.\d+)?$", s))
|
|
45
|
+
|
|
46
|
+
|
|
42
47
|
@dataclass
|
|
43
48
|
class ReplCommand:
|
|
44
49
|
"""Class definition for a provided CLI REPL command"""
|
|
@@ -184,6 +189,21 @@ class ReplBase:
|
|
|
184
189
|
"""Shortcut to console.input"""
|
|
185
190
|
return self.console.input(*args)
|
|
186
191
|
|
|
192
|
+
def input_int(self, *args) -> int:
|
|
193
|
+
"""Parse input as int"""
|
|
194
|
+
|
|
195
|
+
user_input = self.input(*args).strip().split(".")[0].strip()
|
|
196
|
+
if is_num_str(user_input):
|
|
197
|
+
return int(user_input)
|
|
198
|
+
|
|
199
|
+
def input_bool(self, *args, true_list: list[str] = None) -> int:
|
|
200
|
+
"""Parse input as bool"""
|
|
201
|
+
true_list = true_list or ["y", "yes"]
|
|
202
|
+
true_list = [val.lower() for val in true_list]
|
|
203
|
+
|
|
204
|
+
user_input = self.input(*args)
|
|
205
|
+
return user_input.strip().lower() in true_list
|
|
206
|
+
|
|
187
207
|
def debug(self, *args) -> None:
|
|
188
208
|
"""Print only if debug_enabled == True"""
|
|
189
209
|
if self.debug_enabled:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|