class QuPathVersion: """Handle the QuPath version strings""" def __init__(self, version: str) -> None: self.origin = ver_str = str(version).strip() # to not having to rely on packaging.version.LegacyVersion # we replace the milestone versioning with -devNN ver_str = re.sub(r"(?:-)m(?P<num>[0-9]+)", r"dev\g<num>", ver_str, count=1) self.version = Version(ver_str) def __repr__(self) -> str: return f"{type(self).__name__}({self.origin!r})" def __str__(self) -> str: return self.origin def __eq__(self, other) -> bool: if isinstance(other, QuPathVersion): return self.version.__eq__(other.version) else: return self.version.__eq__(other) def __lt__(self, other) -> bool: if isinstance(other, QuPathVersion): return self.version.__lt__(other.version) else: return self.version.__lt__(other)