/usr/lib/python3/dist-packages/UM/Version.py is in python3-uranium 3.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # Copyright (c) 2017 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.
import re #To replace parts of version strings with regex.
class Version(object):
def __init__(self, version):
super().__init__()
if isinstance(version, str):
# Versions are in (MOD-)x.x.x(-x) format.
version = version.replace("MOD-", "")
version = version.replace("-", ".")
version = version.replace("_", ".")
version = re.sub(r"[A-Z]+", "", version)
version_list = version.split(".")
else:
version_list = version
self._major = 0
self._minor = 0
self._revision = 0
try:
self._major = int(version_list[0])
self._minor = int(version_list[1])
self._revision = int(version_list[2])
except IndexError:
pass
except ValueError:
pass
def getMajor(self):
return self._major
def getMinor(self):
return self._minor
def getRevision(self):
return self._revision
def __gt__(self, other):
if isinstance(other, Version):
return other.__lt__(self)
elif isinstance(other, str):
return Version(other).__lt__(self)
else:
return False
def __lt__(self, other):
if isinstance(other, Version):
if self._major < other.getMajor():
return True
if self._minor < other.getMinor() and self._major == other.getMajor():
return True
if self._revision < other.getRevision() and self._major == other.getMajor() and self._minor == other.getMinor():
return True
return False
elif isinstance(other, str):
return self < Version(other)
else:
return False
def __eq__(self, other):
if isinstance(other, Version):
return self._major == other.getMajor() and self._minor == other.getMinor() and self._revision == other.getRevision()
elif isinstance(other, str):
return self == Version(other)
else:
return False
def __str__(self):
return "%s.%s.%s" %(self._major, self._minor, self._revision)
def __hash__(self):
return hash(self.__str__())
|