dicogis.utils.formatters module

Helpers to format text and variables.

dicogis.utils.formatters.convert_octets(octets)

Convert a mount of octets in readable size.

Parameters:

octets (int) – 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)
dicogis.utils.formatters.secure_encoding(layer_dict, key_str)

Check if dictionary value is compatible with XML encoding.

Parameters:
  • layer_dict (dict) – layer metadata dictionary

  • key_str (str) – key fo dictionary to check

Returns:

clean string

Return type:

str