replbase 0.0.46__tar.gz → 0.0.48__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.46
3
+ Version: 0.0.48
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.46"
7
+ version = "0.0.48"
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"
@@ -203,27 +203,29 @@ class CommandMeta:
203
203
  return repl_cmd
204
204
 
205
205
  for arg, parm in self.sig_parms.items():
206
- arg_type = self.type_hints.get(arg, str)
206
+ try:
207
+ arg_type = self.type_hints.get(arg, str)
207
208
 
208
- flag_name = self.flag_names.get(arg)
209
+ flag_name = self.flag_names.get(arg)
209
210
 
210
- cmd_init = {"help": self.args.get(arg)}
211
+ cmd_init = {"help": self.args.get(arg)}
211
212
 
212
- if arg_type == bool:
213
- cmd_init["action"] = (
214
- "store_false" if parm.default is True else "store_true"
215
- )
213
+ if arg_type == bool:
214
+ cmd_init["action"] = (
215
+ "store_false" if parm.default is True else "store_true"
216
+ )
216
217
 
217
- if arg_type not in [str, bool]:
218
- cmd_init["type"] = arg_type
218
+ if arg_type not in [str, bool]:
219
+ cmd_init["type"] = arg_type
219
220
 
220
- if isinstance(arg_type, type) and isinstance(parm.default, arg_type):
221
- cmd_init["default"] = parm.default
221
+ if isinstance(arg_type, type) and isinstance(
222
+ parm.default, arg_type
223
+ ):
224
+ cmd_init["default"] = parm.default
222
225
 
223
- if isinstance(arg_type, list):
224
- cmd_init["nargs"] = "+"
226
+ if isinstance(arg_type, list):
227
+ cmd_init["nargs"] = "+"
225
228
 
226
- try:
227
229
  if cmd_init:
228
230
  repl_cmd.parser.add_argument(flag_name, **cmd_init)
229
231
 
@@ -371,6 +371,31 @@ class ReplBase:
371
371
  key = keys[choice - 1]
372
372
  return choices[key]
373
373
 
374
+ def input_obj_update(self, obj: dict[str, Any]) -> Any:
375
+
376
+ prop_name = self.input_choice(
377
+ "Select property to update: ", choices=list(obj.keys())
378
+ )
379
+ prop = obj[prop_name]
380
+
381
+ if not prop:
382
+ self.warn("Invalid selection")
383
+ return None
384
+
385
+ prompt = f"Enter value for {prop_name}: "
386
+ if prop is str | list[str]:
387
+ return self.input(prompt)
388
+ if prop is int | list[int]:
389
+ return self.input_int(prompt)
390
+ if prop is bool:
391
+ return self.input_bool(prompt)
392
+ if isinstance(prop, EnumType):
393
+ return self.get_enum_val(prompt, prop)
394
+ if isinstance(prop, Enum):
395
+ return self.get_enum_val(prompt, type(prop))
396
+ self.warn("Invalid property type")
397
+ return None
398
+
374
399
  def get_enum_val(self, prompt: str, enum_cls: EnumType) -> Enum:
375
400
  """Prompt the user to select an enum value
376
401
 
File without changes
File without changes