Skip to content
Snippets Groups Projects
Commit 7bb76473 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Moved version number utility functions from FSLeyes into fslpy. And removed

hotfixes - the patch number will be used for maintenance releases.
parent 515205ed
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,76 @@ ...@@ -4,13 +4,76 @@
# #
# Author: Paul McCarthy <pauldmccarthy@gmail.com> # Author: Paul McCarthy <pauldmccarthy@gmail.com>
# #
"""The sole purpose of this module is as a container for the ``fslpy`` """The primary purpose of this module is as a container for the ``fslpy``
version number and information. version number. A couple of conveniense functions for comparing version
numbers are also defined here.
.. autosummary:: .. autosummary::
:nosignatures:
__version__ __version__
parseVersionString
compareVersions
The ``fslpy`` version number consists of three numbers, separated by a period,
which roughly obeys the Semantic Versioning conventions (http://semver.org/):
1. The major release number. This gets updated for major/external releases.
2. The minor release number. This gets updated for minor/internal releases,
which involve new features, bug-fixes, and other updates.
3. The point release number. This gets updated for minor/internal releases,
which primarily involve bug-fixes and minor changes.
""" """
__version__ = '1.0.0' __version__ = '1.0.0'
"""Current version number, as a string. """ """Current version number, as a string. """
def parseVersionString(versionString):
"""Parses the given version string, and returns a tuple containing
the individual components of the version number (see the description
of the :attr:`__version__` attribute).
An error is raised if the ``versionString`` is invalid.
"""
components = versionString.split('.')
# Major, minor, and point
# version are always numeric
major, minor, point = [int(c) for c in components]
return major, minor, point
def compareVersions(v1, v2, ignorePoint=False):
"""Compares the given ``fslpy`` version numbers.
:arg v1: Version number to compare
:arg v2: Version number to compare
:arg ignorePoint: Defaults to ``False``. If ``True``, the point release
numbers are ignored in the comparison.
:returns: One of the following:
- -1 if ``v1`` < ``v2`` (i.e. ``v1`` is older than ``v2``)
- 0 if ``v1`` == ``v2``
- 0 if ``v1`` > ``v2``
"""
v1 = parseVersionString(v1)
v2 = parseVersionString(v2)
if ignorePoint:
v1 = v1[:2]
v2 = v2[:2]
for p1, p2 in zip(v1, v2):
if p1 > p2: return 1
if p1 < p2: return -1
return 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment