示例#1
0
	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
示例#2
0
    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
示例#3
0
	def findFile(self, name):
		trees = self.filetree.keys()

		#
		# look in the local tree first
		#
		if 'local' in trees:
			tree = self.filetree['local']
			for d in tree.getDirs():
				for file in tree.getFiles(d):
					try:
						if file.getPackageName() == name:
							return file
					except:
						pass

					try:
						if file.getName() == name:
							return file
					except:
						pass
		for key in trees:
			if key == 'local':
				continue

			tree = self.filetree[key]
			for d in tree.getDirs():
				for file in tree.getFiles(d):
					try:
						if file.getPackageName() == name:
							return file
					except:
						pass

					try:
						if file.getName() == name:
							return file
					except:
						pass

		return None
示例#4
0
	def findFile(self, name):
		trees = self.filetree.keys()

		#
		# look in the local tree first
		#
		if 'local' in trees:
			tree = self.filetree['local']
			for d in tree.getDirs():
				for file in tree.getFiles(d):
					try:
						if file.getPackageName() == name:
							return file
					except:
						pass

					try:
						if file.getName() == name:
							return file
					except:
						pass
		for key in trees:
			if key == 'local':
				continue

			tree = self.filetree[key]
			for d in tree.getDirs():
				for file in tree.getFiles(d):
					try:
						if file.getPackageName() == name:
							return file
					except:
						pass

					try:
						if file.getName() == name:
							return file
					except:
						pass

		return None