Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_version_string(s):
version_parts = [s for s in s.split('.')]
prerelease = ""
hyphen_index = version_parts[2].find('-')
if hyphen_index != -1:
p = version_parts[2]
version_parts[2] = p[0:hyphen_index]
prerelease = p[hyphen_index + 1:]
return Version(int(version_parts[0]), int(version_parts[1]), int(version_parts[2]), prerelease)
def default(self, o):
if type(o) is Version:
# store as a "MAJOR.MINOR.PATCH" string so it's a little easier to
# read the raw JSON
return o.__str__()
return o.__dict__