qgis_deployment_toolbelt.utils.formatters module#

Helpers to format text and variables.

qgis_deployment_toolbelt.utils.formatters.convert_octets(octets: int) str#

Convert a mount of octets in readable size.

Parameters:

octets – mount of octets to convert

Returns:

ko, Mo, etc.

Return type:

size in a human readable format

Example:

>>> convert_octets(1024)
1 ko
>>> from pathlib import Path
>>> convert_octets(Path(my_file.txt).stat().st_size)
qgis_deployment_toolbelt.utils.formatters.url_ensure_trailing_slash(in_url: str) str#

Make sure an URL has a trailing slash.

Parameters:

in_url (str) – input URL

Returns:

URL with trailing slash added (only if not already present)

Return type:

str