MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / parse_version_info

Function parse_version_info

mogen/version.py:4–20  ·  view source on GitHub ↗

Parse a version string into a tuple. Args: version_str (str): The version string. Returns: tuple[int | str]: The version info, e.g., "1.3.0" is parsed into (1, 3, 0), and "2.0.0rc1" is parsed into (2, 0, 0, 'rc1').

(version_str)

Source from the content-addressed store, hash-verified

2
3
4def parse_version_info(version_str):
5 """Parse a version string into a tuple.
6 Args:
7 version_str (str): The version string.
8 Returns:
9 tuple[int | str]: The version info, e.g., "1.3.0" is parsed into
10 (1, 3, 0), and "2.0.0rc1" is parsed into (2, 0, 0, 'rc1').
11 """
12 version_info = []
13 for x in version_str.split('.'):
14 if x.isdigit():
15 version_info.append(int(x))
16 elif x.find('rc') != -1:
17 patch_version = x.split('rc')
18 version_info.append(int(patch_version[0]))
19 version_info.append(f'rc{patch_version[1]}')
20 return tuple(version_info)
21
22
23version_info = parse_version_info(__version__)

Callers 1

version.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected