From a92ebea86bdf7f5c16f8bd17f1e714582ac162a8 Mon Sep 17 00:00:00 2001 From: Wolfgang Waltenberger Date: Wed, 17 Jan 2024 20:35:48 +0100 Subject: [PATCH] replacing semver object with tuple --- smodels/installation.py | 21 +++++++++++++-------- smodels/share/requirements.txt | 1 - 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/smodels/installation.py b/smodels/installation.py index ecd8290902..08b00dab93 100755 --- a/smodels/installation.py +++ b/smodels/installation.py @@ -11,8 +11,7 @@ from __future__ import print_function import sys import os -from typing import Union -from semver import VersionInfo +from typing import Union, Tuple def installDirectory(): """ @@ -137,22 +136,28 @@ def requirements(): f.close() return ret -def version( return_object : bool = False ) -> Union[str,VersionInfo]: +def version( return_tuple : bool = False ) -> Union[str,Tuple]: """ Returns version number of the SModelS framework. - :param return_object: Return a semver VersionInfo object instead of string - :returns: version, either as string or as semver VersionInfo object + :param return_tuple: Return a tuple of (major,minor,patch,...) instead of string + :returns: version, either as string or tuple """ f = open( f"{installDirectory()}/smodels/version" ) l = f.readline() f.close() l = l.replace("\n", "") l.strip() - if not return_object: + if not return_tuple: return l - import semver - return semver.parse ( l ) + import re + ret = re.split("\.|-",l) + for i,r in enumerate(ret): + try: + ret[i]=int(r) + except ValueError as e: + pass + return tuple(ret) def license(): """ diff --git a/smodels/share/requirements.txt b/smodels/share/requirements.txt index 754dedd734..d4c741dd24 100644 --- a/smodels/share/requirements.txt +++ b/smodels/share/requirements.txt @@ -7,4 +7,3 @@ pyslha>=3.1.0 pyhf>=0.6.1 jsonpatch>=1.25 jsonschema>=3.2.0 -semver>=2.0.0