How to use the pipupgrade.semver.parse function in pipupgrade

To help you get started, we’ve selected a few pipupgrade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github achillesrasquinha / pipupgrade / src / pipupgrade / commands / helper.py View on Github external
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
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / outdated.py View on Github external
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
github achillesrasquinha / pipupgrade / src / pipupgrade / pubgrub.py View on Github external
def __init__(self, *args, **kwargs):
        self._root_version  = semver.parse("0.0.0")

        self.super          = super(PackageSource, self)
        self.super.__init__(*args, **kwargs)