manen.helpers#

Helpers functions used by manen.

manen.helpers.batch(iterable, size: int = 1)[source]#

Slice an iterable into batches of given size.

Parameters:
  • iterable (Iterable) – iterable to slice into batches

  • n (int, optional) – size of each batch. Default to 1.

Return type:

Iterable

manen.helpers.extract(archive_path: str)[source]#

Uncompress a file in an archive.

Parameters:

archive_path (str) – path where to find the archive

Returns:

path of the uncrompressed file

Return type:

str

manen.helpers.extract_integer(string: str) int[source]#

Extract an integer from a string.

Parameters:

string (str) – text to process

Raises:

ValueError – exception raised if no integer were fonnd in the string.

Returns:

integer extracted from the string

Return type:

int

manen.helpers.version(version_str: str) Version[source]#

Helper function to convert a version string into a tuple. The versioning scheme is described here. The input will be validated with the regular expression ^[\d]+.[\d]+.[\d]+.[\d]+$ and raised a ValueError if it doesn’t match.

Caution

This versioning system is not compliant with semantic versioning rules.

Parameters:

version_str – string to be converted to a tuple

Raises:

ValueError – raised if the input doesn’t match the pattern

Returns:

parsed version

Return type:

Tuple[int, int, Optional[int], int]

manen.helpers.version_as_str(version_tuple: Version, limit: int = 4) str[source]#
Format a version tuple as a string in the format:

{major}.{minor}.{build}.{patch}

Parameters:
  • version_tuple (Version) – version info as a tuple

  • limit (int, optional) – Limit on the length of the tuple to format. Defaults to 4.

Returns:

formatted version

Return type:

str