eoio.utils.formatters module#
eoio.utils.formatters - formatting functions for values
- eoio.utils.formatters.is_datetime(s)[source]#
Return whether a string is a datetime
- Parameters:
s – input string
- Returns:
Truewhen the string can be parsed as a datetime, otherwiseFalse.
- eoio.utils.formatters.is_number(s)[source]#
Return whether a string is a number
- Parameters:
s – input str
- Returns:
Truewhen the string can be parsed as a number, otherwiseFalse.
- eoio.utils.formatters.list_to_dict(test_list, key=None) dict[source]#
Convert a list of tuples into a dictionary, based on ‘GROUP’ and ‘END_GROUP’ values
- Parameters:
test_list – list of tuples containing (key, value), (“GROUP”, key) and (“END_GROUP”, key) tuples
key – key of the dictionary into which subsequent key-value pairs are added
- Returns:
Dictionary containing the parsed key-value pairs.
- eoio.utils.formatters.str2datetime(s)[source]#
Convert strings of recognised datetime formats (valid ISO 8601 formats accepted by datetime.datetime.fromisoformat() and datetime.time.fromisoformat()) to datetime objects.
Valid date strings given by: datetime.datetime.fromisoformat() - https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat datetime.time.isoformat() - https://docs.python.org/3/library/datetime.html#datetime.time.fromisoformat
- Parameters:
s – input string
- Returns:
Datetime object, time object, or the original string value.