MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / parse_from_string

Method parse_from_string

tensorflow/tools/ci_build/update_version.py:115–143  ·  view source on GitHub ↗

Returns version object from Semver string. Args: string: version string version_type: version parameter Raises: RuntimeError: If the version string is not valid.

(string, version_type)

Source from the content-addressed store, hash-verified

113
114 @staticmethod
115 def parse_from_string(string, version_type):
116 """Returns version object from Semver string.
117
118 Args:
119 string: version string
120 version_type: version parameter
121
122 Raises:
123 RuntimeError: If the version string is not valid.
124 """
125 # Check validity of new version string.
126 if not re.search(r"[0-9]+\.[0-9]+\.[a-zA-Z0-9]+", string):
127 raise RuntimeError("Invalid version string: %s" % string)
128
129 major, minor, extension = string.split(".", 2)
130
131 # Isolate patch and identifier string if identifier string exists.
132 extension_split = extension.split("-", 1)
133 patch = extension_split[0]
134 if len(extension_split) == 2:
135 identifier_string = "-" + extension_split[1]
136 else:
137 identifier_string = ""
138
139 return Version(major,
140 minor,
141 patch,
142 identifier_string,
143 version_type)
144
145
146def get_current_semver_version():

Callers 1

mainFunction · 0.45

Calls 2

VersionClass · 0.70
splitMethod · 0.45

Tested by

no test coverage detected