replbase 0.0.7__tar.gz → 0.0.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: replbase
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: "Combination of other REPL tools into a reusable class that generates a REPL"
5
5
  License: MIT
6
6
  Author: Joseph Bochinski
@@ -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"
7
+ version = "0.0.9"
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"
@@ -41,7 +41,7 @@ ColorSystem = Literal["auto", "standard", "256", "truecolor", "windows"]
41
41
 
42
42
 
43
43
  def is_num_str(val: str) -> bool:
44
- return bool(re.match(r"^-?\d+(\.\d+)?$", s))
44
+ return bool(re.match(r"^-?\d+(\.\d+)?$", val))
45
45
 
46
46
 
47
47
  @dataclass
@@ -204,6 +204,14 @@ class ReplBase:
204
204
  user_input = self.input(*args)
205
205
  return user_input.strip().lower() in true_list
206
206
 
207
+ def input_prefer_int(self, *args) -> int | str:
208
+ """Parse input as int if possible, otherwise return the string"""
209
+
210
+ user_input = self.input(*args).strip().split(".")[0].strip()
211
+ if is_num_str(user_input):
212
+ return int(user_input)
213
+ return user_input
214
+
207
215
  def debug(self, *args) -> None:
208
216
  """Print only if debug_enabled == True"""
209
217
  if self.debug_enabled:
File without changes
File without changes
File without changes