BinaryPackageUniverse: Implement packages_equivalent_to()

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 6 years ago
parent 530db5d3f7
commit d557610c6f
No known key found for this signature in database
GPG Key ID: A65B78DBE67C7AAC

@ -373,6 +373,7 @@ class InstallabilityTesterBuilder(object):
eqv_table = {} eqv_table = {}
relations = {} relations = {}
emptyset = frozenset() emptyset = frozenset()
intern_set = self._intern_set
for pkg in reverse_package_table: for pkg in reverse_package_table:
rdeps = reverse_package_table[pkg][2] rdeps = reverse_package_table[pkg][2]
@ -385,7 +386,8 @@ class InstallabilityTesterBuilder(object):
find_eqv_table[ekey].append(pkg) find_eqv_table[ekey].append(pkg)
for pkg_relations, pkg_list in find_eqv_table.items(): for pkg_relations, pkg_list in find_eqv_table.items():
rel = BinaryPackageRelation(pkg_relations[0], pkg_relations[1], reverse_package_table[pkg_list[0]][0]) rdeps = reverse_package_table[pkg_list[0]][0]
rel = BinaryPackageRelation(intern_set(pkg_list), pkg_relations[0], pkg_relations[1], rdeps)
if len(pkg_list) < 2: if len(pkg_list) < 2:
relations[pkg_list[0]] = rel relations[pkg_list[0]] = rel
continue continue
@ -398,7 +400,7 @@ class InstallabilityTesterBuilder(object):
for pkg, forward_relations in package_table.items(): for pkg, forward_relations in package_table.items():
if pkg in relations: if pkg in relations:
continue continue
rel = BinaryPackageRelation(forward_relations[0], forward_relations[1], emptyset) rel = BinaryPackageRelation(intern_set((pkg,)), forward_relations[0], forward_relations[1], emptyset)
relations[pkg] = rel relations[pkg] = rel
return relations, eqv_table return relations, eqv_table

@ -106,8 +106,7 @@ class InstallabilityTester(object):
the package dependency graph (i.e. relations can not tell the package dependency graph (i.e. relations can not tell
them apart semantically except for their name). Otherwise False them apart semantically except for their name). Otherwise False
""" """
eqv_table = self._eqv_table return self._universe.are_equivalent(pkg_id1, pkg_id2)
return pkg_id1 in eqv_table and pkg_id2 in eqv_table[pkg_id1]
def reverse_dependencies_of(self, pkg_id): def reverse_dependencies_of(self, pkg_id):
"""Returns the set of reverse dependencies of a given package """Returns the set of reverse dependencies of a given package

@ -16,9 +16,10 @@
class BinaryPackageRelation(object): class BinaryPackageRelation(object):
"""All relations of a given binary package""" """All relations of a given binary package"""
__slots__ = ['dependencies', 'negative_dependencies', 'reverse_dependencies'] __slots__ = ['pkg_ids', 'dependencies', 'negative_dependencies', 'reverse_dependencies']
def __init__(self, dependencies, negative_dependencies, reverse_dependencies): def __init__(self, pkg_ids, dependencies, negative_dependencies, reverse_dependencies):
self.pkg_ids = pkg_ids
self.dependencies = dependencies self.dependencies = dependencies
self.negative_dependencies = negative_dependencies self.negative_dependencies = negative_dependencies
self.reverse_dependencies = reverse_dependencies self.reverse_dependencies = reverse_dependencies
@ -97,7 +98,7 @@ class BinaryPackageUniverse(object):
input package. Note that this set always includes the input input package. Note that this set always includes the input
package assuming it is a known package. package assuming it is a known package.
""" """
return NotImplemented return self._relations[pkg_id].pkg_ids
def relations_of(self, pkg_id): def relations_of(self, pkg_id):
"""Get the direct relations of a given packge """Get the direct relations of a given packge

Loading…
Cancel
Save