Пример #1
0
    def findProduct(self, name, version, flavor):
        """
        find the fully specified declared product given its name, version, 
        and platform flavor, or None if product is not declared.

        @param name :     the name of the desired product
        @param version :  the desired version of the product
        @param flavor :   the desired platform flavor
        @return Product : the matched product or None if not found
        """
        vfile = self._findVersionFile(name, version)
        if vfile is None:
            return None

        verdata = VersionFile(vfile, name, version)
        product = None
        try:
            product = verdata.makeProduct(flavor, self.defStackRoot, 
                                          self.dbpath)
            product.tags = self.findTags(name, version, flavor)
        except ProductNotFound:
            return None

        return product
Пример #2
0
    def findProduct(self, name, version, flavor):
        """
        find the fully specified declared product given its name, version, 
        and platform flavor, or None if product is not declared.

        @param name :     the name of the desired product
        @param version :  the desired version of the product
        @param flavor :   the desired platform flavor
        @return Product : the matched product or None if not found
        """
        vfile = self._findVersionFile(name, version)
        if vfile is None:
            return None

        verdata = VersionFile(vfile, name, version)
        product = None
        try:
            product = verdata.makeProduct(flavor, self.defStackRoot,
                                          self.dbpath)
            product.tags = self.findTags(name, version, flavor)
        except ProductNotFound:
            return None

        return product
Пример #3
0
    def findProducts(self, name, versions=None, flavors=None):
        """
        return a list of Products matching the given inputs

        @param name :     the name of the desired product
        @param versions : the desired versions.  If versions is None, 
                            return all declared versions of the product.
        @param flavors :  the desired flavors.  If None, return matching 
                            products of all declared flavors.
        @return Product[] : a list of the matching products
        """
        if versions is None:
            versions = self.findVersions(name)

        if not isinstance(versions, list):
            versions = [versions]

        if flavors is not None and not isinstance(flavors, list):
            flavors = [flavors]

        out = {}
        for vers in versions:
            vfile = self._versionFile(name, vers)
            if not os.path.exists(vfile):
                continue
            vfile = VersionFile(vfile, name, vers)
                                
            flavs = flavors
            declared = vfile.getFlavors()
            if flavs is None:  flavs = declared
            out[vers] = {}
            for f in flavs:
                if f in declared:
                    out[vers][f] = vfile.makeProduct(f, self.defStackRoot, 
                                                     self.dbpath)

        if len(out.keys()) == 0:
            return []

        pdir = self._productDir(name)
        if not os.path.exists(pdir):
          raise RuntimeError("programmer error: product directory disappeared")

        # add in the tags 
        for tag, vers, flavor in self.getTagAssignments(name):
            try: 
                out[vers][flavor].tags.append(tag)
            except KeyError:
                pass

#  not sure why this doesn't work:
#        out = reduce(lambda x,y: x.extend(y), 
#                     map(lambda z:  z.values(), out.values()))
#        out.sort(_cmp_by_verflav)
#
#  replaced with moral equivalent:
#                          
        v = map(lambda z:  z.values(), out.values())
        x = v[0]
        for y in v[1:]:  x.extend(y)
        x.sort(_cmp_by_verflav)
        return x
Пример #4
0
    def findProducts(self, name, versions=None, flavors=None):
        """
        return a list of Products matching the given inputs

        @param name :     the name of the desired product
        @param versions : the desired versions.  If versions is None, 
                            return all declared versions of the product.
        @param flavors :  the desired flavors.  If None, return matching 
                            products of all declared flavors.
        @return Product[] : a list of the matching products
        """
        if versions is None:
            versions = self.findVersions(name)

        if not isinstance(versions, list):
            versions = [versions]

        if flavors is not None and not isinstance(flavors, list):
            flavors = [flavors]

        out = {}
        for vers in versions:
            vfile = self._versionFile(name, vers)
            if not os.path.exists(vfile):
                continue
            vfile = VersionFile(vfile, name, vers)

            flavs = flavors
            declared = vfile.getFlavors()
            if flavs is None: flavs = declared
            out[vers] = {}
            for f in flavs:
                if f in declared:
                    out[vers][f] = vfile.makeProduct(f, self.defStackRoot,
                                                     self.dbpath)

        if len(out.keys()) == 0:
            return []

        pdir = self._productDir(name)
        if not os.path.exists(pdir):
            raise RuntimeError(
                "programmer error: product directory disappeared")

        # add in the tags
        for tag, vers, flavor in self.getTagAssignments(name):
            try:
                out[vers][flavor].tags.append(tag)
            except KeyError:
                pass


#  not sure why this doesn't work:
#        out = reduce(lambda x,y: x.extend(y),
#                     map(lambda z:  z.values(), out.values()))
#        out.sort(_cmp_by_verflav)
#
#  replaced with moral equivalent:
#
        v = map(lambda z: z.values(), out.values())
        x = v[0]
        for y in v[1:]:
            x.extend(y)
        x.sort(_cmp_by_verflav)
        return x