def getRPMS(self, path): """Return a list of all the RPMs in the given path, if multiple versions of a package are found only the most recent one will be included""" dict = {} tree = stack.file.Tree(os.path.join(os.getcwd(), path)) for dir in tree.getDirs(): for file in tree.getFiles(dir): try: file.getPackageName() except AttributeError: continue # skip all non-rpm files # Skip RPMS for other architecures if file.getPackageArch() not in self.getCPUs(): continue # Resolve package versions name = file.getUniqueName() if not dict.has_key(name) or file >= dict[name]: dict[name] = file # convert the dictionary to a list and return all the RPMFiles list = [] for e in dict.keys(): list.append(dict[e]) return list
def getRPMS(self, path): """Return a list of all the RPMs in the given path, if multiple versions of a package are found only the most recent one will be included""" dict = {} tree = stack.file.Tree(os.path.join(os.getcwd(), path)) for dir in tree.getDirs(): for file in tree.getFiles(dir): try: file.getPackageName() except: continue # skip all non-rpm files # Skip RPMS for other architecures if file.getPackageArch() not in self.getCPUs(): continue # Resolve package versions if newest is True: name = file.getUniqueName() else: name = file.getFullName() if (name not in dict) or (file >= dict[name]): dict[name] = file # convert the dictionary to a list and return all the RPMFiles list = [] for e in dict.keys(): list.append(dict[e]) return list