def isDeclared(self, productName, version=None, flavor=None): """ return true if a product is declared. @param productName : the name of the product to search for @param version : a specific version to look for. If None, return true if any version of this product is available. @param flavor : a specific platform flavor to look for. If None, return true if any flavor is supported by the product. """ pdir = self._productDir(productName) if not os.path.exists(pdir): return False if version is None: if flavor is None: return True vfiles = os.listdir(pdir) for file in vfiles: if (versionFileRe.match(file)): file = VersionFile(os.path.join(pdir,file)) vers = file.version if file.hasFlavor(flavor): return True return False else: file = self._versionFileInDir(pdir, version) if not os.path.exists(file): return False if flavor is None: return True file = VersionFile(file) return file.hasFlavor(flavor)
def isDeclared(self, productName, version=None, flavor=None): """ return true if a product is declared. @param productName : the name of the product to search for @param version : a specific version to look for. If None, return true if any version of this product is available. @param flavor : a specific platform flavor to look for. If None, return true if any flavor is supported by the product. """ pdir = self._productDir(productName) if not os.path.exists(pdir): return False if version is None: if flavor is None: return True vfiles = os.listdir(pdir) for file in vfiles: if (versionFileRe.match(file)): file = VersionFile(os.path.join(pdir, file)) vers = file.version if file.hasFlavor(flavor): return True return False else: file = self._versionFileInDir(pdir, version) if not os.path.exists(file): return False if flavor is None: return True file = VersionFile(file) return file.hasFlavor(flavor)
def undeclare(self, product): """ undeclare the given Product. Only the name, version, and flavor will be paid attention to. False is returned if the product was not found in the database. @param product : the Product instance to undeclare. @return bool : False if nothing was undeclared @throws UnderSpecifiedProduct if the name, version, and flavor are not all set """ if not isinstance(product, Product): raise RuntimeError("Database.declare(): argument not a Product: " + product) if not product.name or not product.version or not product.flavor: raise UnderSpecifiedProduct( msg="Product not fully specified: %s %s %s" % (str(product.name), str(product.version), str(product.flavor)) ) pdir = self._productDir(product.name) vfile = self._versionFileInDir(pdir, product.version) if not os.path.exists(vfile): return False versionFile = VersionFile(vfile) if versionFile.hasFlavor(product.flavor): # unassign tags associated with this product tags = self.findTags(product.name, product.version, product.flavor) for tag in tags: self.unassignTag(tag, product.name, product.flavor) changed = versionFile.removeFlavor(product.flavor) if changed: versionFile.write() # do a little clean up: if we got rid of the version file, try # deleting the directory if not os.path.exists(vfile): try: os.rmdir(pdir) except: pass return changed
def undeclare(self, product): """ undeclare the given Product. Only the name, version, and flavor will be paid attention to. False is returned if the product was not found in the database. @param product : the Product instance to undeclare. @return bool : False if nothing was undeclared @throws UnderSpecifiedProduct if the name, version, and flavor are not all set """ if not isinstance(product, Product): raise RuntimeError("Database.declare(): argument not a Product: " + product) if not product.name or not product.version or not product.flavor: raise UnderSpecifiedProduct( msg="Product not fully specified: %s %s %s" % (str(product.name), str(product.version), str(product.flavor))) pdir = self._productDir(product.name) vfile = self._versionFileInDir(pdir, product.version) if not os.path.exists(vfile): return False versionFile = VersionFile(vfile) if versionFile.hasFlavor(product.flavor): # unassign tags associated with this product tags = self.findTags(product.name, product.version, product.flavor) for tag in tags: self.unassignTag(tag, product.name, product.flavor) changed = versionFile.removeFlavor(product.flavor) if changed: versionFile.write() # do a little clean up: if we got rid of the version file, try # deleting the directory if not os.path.exists(vfile): try: os.rmdir(pdir) except: pass return changed