LooseVersion

class audeer.LooseVersion(version=None)[source]

Version numbering for anarchists and software realists.

This implementation was originally part of distutils as version.LooseVersion.

A version number consists of a series of numbers, separated by either periods or strings of letters. When comparing version numbers, the numeric components will be compared numerically, and the alphabetic components lexically. The following are all valid version numbers, in no particular order: '1.5.1, '1.5.2b2, '161', '3.10a', '8.02', '3.4j', '1996.07.12', '3.2.pl0', '3.1.1.6', '2g6', '11g', '0.960923', '2.2beta29', '1.13++', '5.5.kw', '2.0b1pl0'.

Parameters

version – version string

Examples

>>> v1 = LooseVersion("1.17.2")
>>> v1
LooseVersion ('1.17.2')
>>> v1.version
[1, 17, 2]
>>> v2 = LooseVersion("1.17.2-3-g70b71bd")
>>> v1 < v2
True

__eq__()

LooseVersion.__eq__(other)[source]

Check if version equals another version.

__ge__()

LooseVersion.__ge__(other)[source]

Check if version is greater or equal another version.

__gt__()

LooseVersion.__gt__(other)[source]

Check if version is greater than another version.

__le__()

LooseVersion.__le__(other)[source]

Check if version is less or equal another version.

__lt__()

LooseVersion.__lt__(other)[source]

Check if version is less than another version.

__repr__()

LooseVersion.__repr__()

Python code to recreate instance.

__str__()

LooseVersion.__str__()[source]

String representation of version.

parse()

LooseVersion.parse(version)[source]

Parse a version string.

When called this updates the stored version under self.version.

Parameters

version – version string

version

LooseVersion.version

Parsed version.

version_re

LooseVersion.version_re = re.compile('(\\d+ | [a-z]+ | \\.)', re.VERBOSE)

Version regexp pattern.

The regexp pattern is used to split the version into single components when parsing it.