maestral.utils
#
Utility modules and functions
Submodules#
Package Contents#
- maestral.utils.natural_size(num, unit='B', sep=True)[source]#
Convert number to a human-readable string with decimal prefix.
- maestral.utils.clamp(n, minn, maxn)[source]#
Clamps a number between a minimum and maximum value.
- Parameters:
n (_N) – Original value.
minn (_N) – Minimum allowed value.
maxn (_N) – Maximum allowed value.
- Returns:
Clamped value.
- Return type:
_N
- maestral.utils.get_newer_version(version, releases)[source]#
Checks a given release version against a version list of releases to see if an update is available. Only offers newer versions if they are not a prerelease.
- maestral.utils.removeprefix(string, prefix, case_sensitive=True)[source]#
Removes the given prefix from a string. Only the first instance of the prefix is removed. The original string is returned if it does not start with the given prefix.
This follows the Python 3.9 implementation of
str.removeprefix
.
- maestral.utils.sanitize_string(string)[source]#
Converts a string provided by file system APIs, which may contain surrogate escapes for bytes with unknown encoding, to a string which can always be displayed or printed. This is done by replacing invalid characters with “�”.
- maestral.utils.exc_info_tuple(exc)[source]#
Creates an exc-info tuple from an exception.
- Parameters:
exc (BaseException) –
- Return type:
_ExecInfoType