swimlane.utils.version module

swimlane.utils.version.compare_versions(version_a, version_b, zerofill=False)[source]

Return direction of version relative to provided version sections

Parameters:
  • version_a (str) – First version to compare

  • version_b (str) – Second version to compare

  • zerofill (bool) – If True, treat any missing version sections as 0, otherwise ignore section. Defaults to False

Returns:

0 if equal, -1 if a > b, 1 if a < b

Return type:

int

Examples

If a is equal to b, return 0 If a is greater than b, return -1 If a is less than b, return 1

>>> compare_versions('2', '2') == 0
>>> compare_versions('2', '1') == -1
>>> compare_versions('2', '3') == 1

If zerofill is False (default), sections not included in both versions are ignored during comparison

>>> compare_versions('2.13.2', '2.13') == 0
>>> compare_versions('2.13.2-1234', '3') == 1

If zerofill is True, any sections in one version not included in other version are set to 0

>>> compare_versions('2.13.2', '2.13', True) == -1
>>> compare_versions('2.13.2-1234', '2.13.2', True) == -1
>>> compare_versions('2.13.2', '2.13.2', True) == 0
swimlane.utils.version.get_package_version()[source]

Get swimlane package version

Returns:

Installed swimlane lib package version, or 0.0.0.dev if not fully installed

Return type:

str

swimlane.utils.version.requires_swimlane_version(min_version=None, max_version=None)[source]

Decorator for SwimlaneResolver methods verifying Swimlane server build version is within a given inclusive range

Raises:
  • InvalidVersion – Raised before decorated method call if Swimlane server version is out of provided range

  • ValueError – If neither min_version or max_version were provided, or if those values conflict (2.15 < 2.14)