IO Helper Functions#

expectmine.io.utils.parse_number(number: str) int | float[source]#

Parses the returned value into an int or float.

Parameters:

number (str) – Number to parses.

Example:

>>> parse_number("12.3")
12.3
>>> parse_number("1")
1
expectmine.io.utils.parse_path(path: str)[source]#

Parses the returned value into a Path object.

Parameters:

path (str) – Number to parses.

Example:

>>> parse_path("foo.txt")
Path("foo.txt")
expectmine.io.utils.validate_arguments(key: str, message: str)[source]#

Validates that the arguments are valid. Throws an error if not.

Parameters:
  • key (str) – Key used to identify the user input.

  • message (str) – Message displayed to the user when asked the question.

Example:

>>> validate_arguments("hello", "world")
>>> validate_arguments("")
ValueError("Key can not be empty")
Raises:
  • TypeError – If the arguments have the wrong type.

  • ValueError – If the key is empty.

expectmine.io.utils.validate_choice(options: list[tuple[str, Any]])[source]#
expectmine.io.utils.validate_step_name(step_name: str)[source]#