Esempio n. 1
0
File: core.py Progetto: jlisee/xpkg
    def lookup(self, name, version=None):
        """
        Grabs the data for the specific packages, returning either the specific
        package, or the most recent version.  If the version can't be found,
        None is returned.

        Currently the data is the path to the archive itself.
        """

        # Get all versions of a package
        versions = self._db.get(name, [])

        res = None

        if len(versions):
            if version and (version in versions):
                # Version specified and we have it
                res = versions[version]
            elif version is None:
                # Sorted the version data pairs
                sorted_versions = sorted(
                    versions.items(),
                    cmp = lambda a,b: util.compare_versions(a[0], b[0]))

                # Get the data for the most recent version
                return sorted_versions[-1][1]

        return res
Esempio n. 2
0
    def lookup(self, name, version=None):
        """
        Grabs the data for the specific packages, returning either the specific
        package, or the most recent version.  If the version can't be found,
        None is returned.

        Currently the data is the path to the archive itself.
        """

        # Get all versions of a package
        versions = self._db.get(name, [])

        res = None

        if len(versions):
            if version and (version in versions):
                # Version specified and we have it
                res = versions[version]
            elif version is None:
                # Sorted the version data pairs
                sorted_versions = sorted(
                    versions.items(),
                    cmp=lambda a, b: util.compare_versions(a[0], b[0]))

                # Get the data for the most recent version
                return sorted_versions[-1][1]

        return res
Esempio n. 3
0
    def lookup(self, package, version=None):
        """
        Get the most recent version of the package in any source, or the
        version specified if it exists in any.
        """

        if version:
            # We have a version so search our trees in order until we find it
            for source in self._sources:
                result = source.lookup(package, version)

                # Bail out if we have found the package
                if result:
                    break
        else:
            # With no version we grab all version of the package then get the
            # most recent

            # Grab all the package versions
            pkgs = []

            for source in self._sources:
                result = source.lookup(package)
                if result:
                    pkgs.append(result)

            # If we have any packages sort by the version
            if len(pkgs) > 0:
                sorter = lambda a, b: util.compare_versions(
                    a.version, b.version)
                sorted_pkgs = sorted(pkgs, cmp=sorter)

                # Get the data for the most recent version
                result = sorted_pkgs[-1]
            else:
                result = None

        return result
Esempio n. 4
0
File: core.py Progetto: jlisee/xpkg
    def lookup(self, package, version=None):
        """
        Get the most recent version of the package in any source, or the
        version specified if it exists in any.
        """

        if version:
            # We have a version so search our trees in order until we find it
            for source in self._sources:
                result = source.lookup(package, version)

                # Bail out if we have found the package
                if result:
                    break
        else:
            # With no version we grab all version of the package then get the
            # most recent

            # Grab all the package versions
            pkgs = []

            for source in self._sources:
                result = source.lookup(package)
                if result:
                    pkgs.append(result)

            # If we have any packages sort by the version
            if len(pkgs) > 0:
                sorter = lambda a,b: util.compare_versions(a.version, b.version)
                sorted_pkgs = sorted(pkgs, cmp=sorter)

                # Get the data for the most recent version
                result = sorted_pkgs[-1]
            else:
                result = None

        return result
Esempio n. 5
0
 def do_compare(self, a, b, val, strtype):
     res = util.compare_versions(a,b)
     args = (a, strtype, b)
     self.assertEqual(val, res, 'Expected version: "%s" %s "%s"' % args)