Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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))