From b1f8f7f3006a30c7590423d215e6c58daca4f8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kope=C4=87?= <3338226+mkopec87@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:52:22 +0100 Subject: [PATCH] * Refactor version.py --- histogrammar/version.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/histogrammar/version.py b/histogrammar/version.py index bb60b61..0648a0c 100644 --- a/histogrammar/version.py +++ b/histogrammar/version.py @@ -1,23 +1,24 @@ -"""THIS FILE IS AUTO-GENERATED BY SETUP.PY.""" - import re +from typing import Tuple -name = "histogrammar" -__version__ = "1.0.34" version = "1.0.34" -full_version = "1.0.34" -release = True -version_info = tuple(re.split(r"[-\.]", __version__)) -specification = ".".join(version_info[:2]) +def split_version_string(version_string: str) -> Tuple[int, int]: + version_numbers = list(map(int, re.split(r"[-.]", version_string))) + return version_numbers[0], version_numbers[1] + + +specification = ".".join([str(i) for i in split_version_string(version)[:2]]) + + +def compatible(serialized_version: str) -> bool: + self_major, self_minor = split_version_string(version) + other_major, other_minor = split_version_string(serialized_version) -def compatible(serializedVersion): - selfMajor, selfMinor = map(int, version_info[:2]) - otherMajor, otherMinor = map(int, re.split(r"[-\.]", serializedVersion)[:2]) - if selfMajor >= otherMajor: + if self_major >= other_major: return True - elif selfMinor >= otherMinor: + elif self_minor >= other_minor: return True else: return False