task_script_utils.parse module#
A collection of useful functions to parse raw values into a more useable form.
- to_int(value: str) int | None[source]#
Converts given value to its equivalent integer.
- Parameters:
value – A string to convert
- Returns:
The int value of the input string or None if the string could not be parsed to int
- to_float(value: str) float | None[source]#
Converts given value to its equivalent float.
- Parameters:
value – A string to convert
- Returns:
The float value of the input string. None if the string could not be parsed to float
- to_decimal(value: str) Decimal | None[source]#
Converts the given value to its equivalent python Decimal type
- Parameters:
value – The value to convert
- Returns:
The decimal value of the input string. None if the string could not be converted to Decimal
- to_boolean(value: str, true_set: Set[str], false_set: Set[str], case_sensitive: bool = False) bool | None[source]#
Convert given string to a boolean value based on whether it is in either of the sets provided
- Parameters:
value – A string to convert
true_set – A set of strings which represent True values
false_set – A set of strings which represent False values
- Returns:
The boolean value of the input string or None if the string could not be parsed to boolean
- Raises:
ValueError – If the sets overlap or if either set is empty