Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _cli_format_semver(version, type_):
def _format(x):
return cli_format(x, cli.YELLOW)
try:
semver.parse(version)
if type_ == "major":
version = _format(version)
if type_ == "minor":
index = version.find(".", 1) + 1
head, tail = version[:index], version[index:]
version = "".join([head, _format(tail)])
if type_ == "patch":
index = version.find(".", 2) + 1
head, tail = version[:index], version[index:]
version = "".join([head, _format(tail)])
except ValueError:
pass
return version
def _cli_format_semver(version, type_):
def format_yellow(string):
string = cli_format(string, cli.YELLOW)
return string
semver.parse(version)
if type_ == "major":
version = format_yellow(version)
if type_ == "minor":
index = version.find(".", 1) + 1
head, tail = version[:index], version[index:]
version = "".join([head, format_yellow(tail)])
if type_ == "patch":
index = version.find(".", 2) + 1
head, tail = version[:index], version[index:]
version = "".join([head, format_yellow(tail)])
return version
def __init__(self, *args, **kwargs):
self._root_version = semver.parse("0.0.0")
self.super = super(PackageSource, self)
self.super.__init__(*args, **kwargs)