Utils Module
The utils module provides common utility functions and helper methods.
utils
Utility functions for version comparison and other common operations.
This module provides semantic version comparison utilities with custom handling for pre-release versions and wildcard version strings.
Functions
isVersionBefore(_compare_to_version, _current_version)
Check if the current version is before (older than) the comparison version.
This function performs a modified semantic version comparison where pre-release versions are treated as equal to their base release version. For example, '8.6.0-pre.m1dev86' is normalized to '8.6.0' before comparison. Wildcard versions like '8.6.x' are converted to '8.6.0'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_compare_to_version
|
str
|
The version to compare against (e.g., "8.6.0"). |
required |
_current_version
|
str
|
The current version to check (e.g., "8.5.0" or "8.6.0-pre.m1dev86"). Can be None, in which case False is returned. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if current_version < compare_to_version, False otherwise. Returns False if _current_version is None. |
Note
This differs from strict semantic versioning where pre-release versions are considered less than their base version.
Source code in src/mas/devops/utils.py
isVersionEqualOrAfter(_compare_to_version, _current_version)
Check if the current version is equal to or after (newer than) the comparison version.
This function performs a modified semantic version comparison where pre-release versions are treated as equal to their base release version. For example, '8.6.0-pre.m1dev86' is normalized to '8.6.0' before comparison. Wildcard versions like '8.6.x' are converted to '8.6.0'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_compare_to_version
|
str
|
The version to compare against (e.g., "8.6.0"). |
required |
_current_version
|
str
|
The current version to check (e.g., "8.7.0" or "8.6.0-pre.m1dev86"). Can be None, in which case False is returned. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if current_version >= compare_to_version, False otherwise. Returns False if _current_version is None. |
Note
This differs from strict semantic versioning where pre-release versions are considered less than their base version.