deepcave.utils.util¶
# Util
This module provides utilities for string generation and shortening. It also provides a function to get the difference between now and a given timestamp.
Functions
|
Get the difference between now and a given timestamp. |
|
Get a random string with a specific length. |
|
Shorten the given string. |
- deepcave.utils.util.get_latest_change(st_mtime)[source]¶
Get the difference between now and a given timestamp.
- Parameters:
st_mtime (int) – A timestamp to calculate the difference from.
- Returns:
A string containing the passed time.
- Return type:
str
- deepcave.utils.util.get_random_string(length)[source]¶
Get a random string with a specific length.
- Parameters:
length (int) – The length of the string.
- Returns:
The random string with the given length.
- Return type:
str
- Raises:
ValueError – If the length is smaller 0.
- deepcave.utils.util.short_string(value, length=30, *, mode='prefix')[source]¶
Shorten the given string.
Cut either at prefix or at suffix if necessary.
- Parameters:
value (Any) – The value or string to shorten.
length (int, optional) – The length of the returned string. Default is 30.
mode (str, optional) – Define how to shorten the string. Default is “prefix”.
- Returns:
The shortened string.
- Return type:
str
- Raises:
ValueError – If the given mode is unknown.