mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-16 03:55:28 +00:00
✨ Add version info
This commit is contained in:
parent
5f5c222f17
commit
e38c48d43c
33
simnet/version.py
Normal file
33
simnet/version.py
Normal file
@ -0,0 +1,33 @@
|
||||
from typing import NamedTuple
|
||||
|
||||
__all__ = ("__version__", "__version_info__")
|
||||
|
||||
|
||||
class Version(NamedTuple):
|
||||
"""Copies the behavior of sys.version_info. serial is always 0 for stable releases."""
|
||||
|
||||
major: int
|
||||
minor: int
|
||||
micro: int
|
||||
release_level: str
|
||||
serial: int
|
||||
|
||||
def _rl_shorthand(self) -> str: # skipcq: PY-D0003
|
||||
return {
|
||||
"alpha": "a",
|
||||
"beta": "b",
|
||||
"candidate": "rc",
|
||||
}[self.release_level]
|
||||
|
||||
def __str__(self) -> str:
|
||||
version = f"{self.major}.{self.minor}"
|
||||
if self.micro != 0:
|
||||
version = f"{version}.{self.micro}"
|
||||
if self.release_level != "final":
|
||||
version = f"{version}{self._rl_shorthand()}{self.serial}"
|
||||
|
||||
return version
|
||||
|
||||
|
||||
__version_info__ = Version(major=1, minor=0, micro=0, release_level="beta", serial=0)
|
||||
__version__ = str(__version_info__)
|
Loading…
Reference in New Issue
Block a user