phenopacket_mapper.utils.parsing.parse_primitive_data_value module
- phenopacket_mapper.utils.parsing.parse_primitive_data_value.parse_primitive_data_value(value_str: str) str | bool | int | float [source]
Parses an int, float, bool, or string from a string value.
Relies on the inbuilt Python type conversion functions to parse the value_str.
- Parameters:
value_str – The string value to be parsed.
- Returns:
The parsed value as an int, float, bool, or string.
- phenopacket_mapper.utils.parsing.parse_primitive_data_value.parse_int(int_str: str) int | None [source]
Parses an int from a string value.
If the string value cannot be parsed as an int, None is returned.
- Parameters:
int_str – The string value to be parsed.
- Returns:
The parsed value as an int. Or None if the string value cannot be parsed as an int.
- phenopacket_mapper.utils.parsing.parse_primitive_data_value.parse_float(float_str: str) float | None [source]
Parses a float from a string value.
If the string value cannot be parsed as a float, None is returned.
- Parameters:
float_str – The string value to be parsed.
- Returns:
The parsed value as a float. Or None if the string value cannot be parsed as a float.
- phenopacket_mapper.utils.parsing.parse_primitive_data_value.parse_bool(bool_str: str) bool | None [source]
Parses a boolean from a string value.
If the string value cannot be parsed as a boolean, None is returned.
On purpose does not parse 0 and 1 to False and True respectively, to avoid confusion with numeric values.
- Parameters:
bool_str – The string value to be parsed.
- Returns:
The parsed value as a boolean. Or None if the string value cannot be parsed as a boolean.