def pick_best_registry_version(self, versions, spec=None): best = None for version in self.filter_incompatible_registry_versions(versions, spec): semver = cast_version_to_semver(version["name"]) if not best or (semver > cast_version_to_semver(best["name"])): best = version return best
def pick_best_registry_version(self, versions, spec=None): assert not spec or isinstance(spec, PackageSpec) best = None for version in versions: semver = cast_version_to_semver(version["name"]) if spec and spec.requirements and semver not in spec.requirements: continue if not any( self.is_system_compatible(f.get("system")) for f in version["files"]): continue if not best or (semver > cast_version_to_semver(best["name"])): best = version return best
def filter_incompatible_registry_versions(self, versions, spec=None): assert not spec or isinstance(spec, PackageSpec) result = [] for version in versions: semver = cast_version_to_semver(version["name"]) if spec and spec.requirements and semver not in spec.requirements: continue if not any( self.is_system_compatible(f.get("system")) for f in version["files"] ): continue result.append(version) return result
def __setattr__(self, name, value): if (value and name in ("current", "latest", "wanted") and not isinstance(value, semantic_version.Version)): value = cast_version_to_semver(str(value)) return super(PackageOutdatedResult, self).__setattr__(name, value)
def version(self, value): if not value: self._version = None return self._version = (value if isinstance(value, semantic_version.Version) else cast_version_to_semver(value))