MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse

Method parse

misc/python/materialize/mz_version.py:49–68  ·  view source on GitHub ↗

Parses a version string with prefix, for example: v0.45.0-dev (f01773cb1) or v0.115.0-dev.0

(cls: type[T], version: str, drop_dev_suffix: bool = False)

Source from the content-addressed store, hash-verified

47
48 @classmethod
49 def parse(cls: type[T], version: str, drop_dev_suffix: bool = False) -> T:
50 """Parses a version string with prefix, for example: v0.45.0-dev (f01773cb1) or v0.115.0-dev.0"""
51 expected_prefix = cls.get_prefix()
52 if not version.startswith(expected_prefix):
53 raise ValueError(
54 f"Invalid version string '{version}', expected prefix '{expected_prefix}'"
55 )
56 version = version.removeprefix(expected_prefix)
57 if " " in version:
58 version, git_hash = version.split(" ")
59 if not git_hash[0] == "(" or not git_hash[-1] == ")":
60 raise ValueError(f"Invalid mz version string: {version}")
61 # Hash ignored
62
63 if drop_dev_suffix:
64 version, _, _ = version.partition("-dev")
65
66 result = super().parse(version)
67 assert isinstance(result, cls)
68 return result
69
70 @classmethod
71 def try_parse(

Callers 13

createMethod · 0.45
parse_without_prefixMethod · 0.45
try_parseMethod · 0.45
parse_mzMethod · 0.45
get_version_tagsFunction · 0.45
parse_versionFunction · 0.45
get_mz_versionFunction · 0.45
mainFunction · 0.45
load_compositionFunction · 0.45

Calls 4

ValueErrorClass · 0.85
partitionMethod · 0.80
get_prefixMethod · 0.45
splitMethod · 0.45

Tested by 1