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.