magpie.compat

Module Contents

Classes

VersionInterface

LooseVersion

This class abstracts handling of a project's versions.

class magpie.compat.VersionInterface[source]

Bases: object

abstract property major: int[source]
abstract property minor: int[source]
abstract property patch: int[source]
class magpie.compat.LooseVersion(version: str)[source]

Bases: packaging.version.Version, VersionInterface

This class abstracts handling of a project’s versions.

A Version instance is comparison aware and can be compared and sorted using the standard Python interfaces.

>>> v1 = Version("1.0a5")
>>> v2 = Version("1.0")
>>> v1
<Version('1.0a5')>
>>> v2
<Version('1.0')>
>>> v1 < v2
True
>>> v1 == v2
False
>>> v1 > v2
False
>>> v1 >= v2
False
>>> v1 <= v2
True

Initialize a Version object.

Parameters:

version – The string representation of a version which will be parsed and normalized before use.

Raises:

InvalidVersion – If the version does not conform to PEP 440 in any way then this exception will be raised.

property version: Tuple[int | str, Ellipsis][source]
property patch[source]
_cmp(other: LooseVersion | str) int[source]