Skip to content

Commit

Permalink
replacing semver object with tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangWaltenberger committed Jan 17, 2024
1 parent 14e80a1 commit a92ebea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 13 additions & 8 deletions smodels/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down Expand Up @@ -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():
"""
Expand Down
1 change: 0 additions & 1 deletion smodels/share/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ pyslha>=3.1.0
pyhf>=0.6.1
jsonpatch>=1.25
jsonschema>=3.2.0
semver>=2.0.0

0 comments on commit a92ebea

Please sign in to comment.