How to use the pipupgrade.semver.difference 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 _format_package(package):
	difference = None
	
	try:
		difference = semver.difference(package.current_version,
			package.latest_version)
	except (TypeError, ValueError):
		pass

	string = "* %s" % cli_format(package.name, _SEMVER_COLOR_MAP.get(difference, cli.CLEAR))

	if getattr(package, "has_dependency_conflict", False):
		string += cli_format(" [dependency conflict]", cli.RED)

	if package.current_version:
		string += " (%s)" % package.current_version

	if package.latest_version and package.current_version != package.latest_version:
		string += " -> (%s)" % _cli_format_semver(package.latest_version, difference)

	string += " " + cli_format("[%s]" % package.home_page, cli.CYAN)
github achillesrasquinha / pipupgrade / src / pipupgrade / commands / outdated.py View on Github external
packages = get_installed_distributions()
    info     = [ ]

    for package in packages:
        package_info    = _get_pypi_package_info(package.project_name, raise_err = raise_err) or { }

        project_name    = package.project_name

        version_current = package.version
        version_latest  = package_info.get("version")
        
        diff_type       = None

        if version_latest and version_current != version_latest:
            try:
                diff_type = semver.difference(version_current, version_latest)
            except ValueError:
                if raise_err:
                    raise

        info.append(dict(
            name             = package_info.get("name"),
            project_name     = project_name,
            version          = version_current,
            latest_version   = version_latest,
            semver_diff_type = diff_type,
            home_page        = package_info.get("home_page")
        ))

    return info
github achillesrasquinha / pipupgrade / src / pipupgrade / model / package.py View on Github external
def difference(self):
		difference = None

		try:
			difference = semver.difference(
				self.current_version,
				self.latest_version
			)
		except (TypeError, ValueError):
			pass

		return difference