Example #1
0
def find_all_packages(prefilter=None):
    """Returns a list of all known packages, installed or not, after applying
	the prefilter function"""
    warnings.warn("Deprecated. Use helpers2.get_cpvs.", DeprecationWarning)
    t = porttree.dbapi.cp_all()
    t += vartree.dbapi.cp_all()
    if prefilter:
        t = list(filter(prefilter, t))
    t = unique_array(t)
    t2 = []
    for x in t:
        t2 += porttree.dbapi.cp_list(x)
        t2 += vartree.dbapi.cp_list(x)
    t2 = unique_array(t2)
    return [Package(x) for x in t2]
Example #2
0
def find_all_packages(prefilter=None):
	"""Returns a list of all known packages, installed or not, after applying
	the prefilter function"""
	warnings.warn("Deprecated. Use helpers2.get_cpvs.", DeprecationWarning)
	t = porttree.dbapi.cp_all()
	t += vartree.dbapi.cp_all()
	if prefilter:
		t = list(filter(prefilter,t))
	t = unique_array(t)
	t2 = []
	for x in t:
		t2 += porttree.dbapi.cp_list(x)
		t2 += vartree.dbapi.cp_list(x)
	t2 = unique_array(t2)
	return [Package(x) for x in t2]
Example #3
0
def find_packages(search_key, masked=False):
    """Returns a list of Package objects that matched the search key."""
    warnings.warn("Deprecated. Use helpers2.find_packages.",
                  DeprecationWarning)
    try:
        if masked:
            t = portage.db[portage.root]["porttree"].dbapi.xmatch(
                "match-all", search_key)
            t += portage.db[portage.root]["vartree"].dbapi.match(search_key)
        else:
            t = portage.db[portage.root]["porttree"].dbapi.match(search_key)
            t += portage.db[portage.root]["vartree"].dbapi.match(search_key)
    # catch the "amgigous package" Exception
    except ValueError as e:
        if isinstance(e[0], list):
            t = []
            for cp in e[0]:
                if masked:
                    t += portage.db[portage.root]["porttree"].dbapi.xmatch(
                        "match-all", cp)
                    t += portage.db[portage.root]["vartree"].dbapi.match(cp)
                else:
                    t += portage.db[portage.root]["porttree"].dbapi.match(cp)
                    t += portage.db[portage.root]["vartree"].dbapi.match(cp)
        else:
            raise ValueError(e)
    except portage_exception.InvalidAtom as e:
        print(warn("Invalid Atom: '%s'" % str(e)))
        return []
    # Make the list of packages unique
    t = unique_array(t)
    t.sort()
    return [Package(x) for x in t]
Example #4
0
def find_packages(search_key, masked=False):
	"""Returns a list of Package objects that matched the search key."""
	warnings.warn("Deprecated. Use helpers2.find_packages.", DeprecationWarning)
	try:
		if masked:
			t = portage.db[portage.root]["porttree"].dbapi.xmatch("match-all", search_key)
			t += portage.db[portage.root]["vartree"].dbapi.match(search_key)
		else:
			t = portage.db[portage.root]["porttree"].dbapi.match(search_key)
			t += portage.db[portage.root]["vartree"].dbapi.match(search_key)
	# catch the "amgigous package" Exception
	except ValueError as e:
		if isinstance(e[0],list):
			t = []
			for cp in e[0]:
				if masked:
					t += portage.db[portage.root]["porttree"].dbapi.xmatch("match-all", cp)
					t += portage.db[portage.root]["vartree"].dbapi.match(cp)
				else:
					t += portage.db[portage.root]["porttree"].dbapi.match(cp)
					t += portage.db[portage.root]["vartree"].dbapi.match(cp)
		else:
			raise ValueError(e)
	except portage_exception.InvalidAtom as e:
		print(warn("Invalid Atom: '%s'" % str(e)))
		return []
	# Make the list of packages unique
	t = unique_array(t)
	t.sort()
	return [Package(x) for x in t]
	def testUniqueArrayPass(self):
		"""
		test portage.util.uniqueArray()
		"""

		tests = [ ( ["a","a","a",os,os,[],[],[]], ['a',os,[]] ), 
			  ( [1,1,1,2,3,4,4] , [1,2,3,4]) ]

		for test in tests:
			result = unique_array( test[0] )
			for item in test[1]:
				number = result.count(item)
				self.assertFalse( number != 1, msg=("%s contains %s of %s, "
					"should be only 1") % (result, number, item) )
Example #6
0
	def testUniqueArrayPass(self):
		"""
		test portage.util.uniqueArray()
		"""

		tests = [ ( ["a","a","a",os,os,[],[],[]], ['a',os,[]] ), 
			  ( [1,1,1,2,3,4,4] , [1,2,3,4]) ]

		for test in tests:
			result = unique_array( test[0] )
			for item in test[1]:
				number = result.count(item)
				self.failIf( number is not 1, msg="%s contains %s of %s, \
					should be only 1" % (result, number, item) )
	def testUniqueArrayPass(self):
		"""
		test portage.util.uniqueArray()
		"""

		tests = [
			(['a', 'a', 'a', os, os, [], [], []], ['a', os, []]),
			([1, 1, 1, 2, 3, 4, 4], [1, 2, 3, 4])
		]

		for test in tests:
			result = unique_array(test[0])
			for item in test[1]:
				number = result.count(item)
				self.assertFalse(number != 1, msg=("%s contains %s of %s, "
					"should be only 1") % (result, number, item))