diff options
| -rw-r--r-- | apt/cache.py | 37 | ||||
| -rw-r--r-- | debian/changelog | 1 |
2 files changed, 23 insertions, 15 deletions
diff --git a/apt/cache.py b/apt/cache.py index 5d76bca2..2008fbc0 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -277,27 +277,34 @@ class Cache(object): else: return bool(pkg.provides_list and not pkg.version_list) - def get_providing_packages(self, virtual): - """ + def get_providing_packages(self, virtual, candidate_only=True): + """Return a list of all packages providing a virtual package. + Return a list of packages which provide the virtual package of the - specified name + specified name. If 'candidate_only' is False, return all packages + with at least one version providing the virtual package. Otherwise, + return only those packages where the candidate version provides + the virtual package. """ - providers = [] + + providers = set() + get_candidate_ver = self._depcache.get_candidate_ver try: vp = self._cache[virtual] if len(vp.version_list) != 0: - return providers + return list(providers) except KeyError: - return providers - for pkg in self: - v = self._depcache.get_candidate_ver(pkg._pkg) - if v is None: - continue - for p in v.provides_list: - if virtual == p[0]: - # we found a pkg that provides this virtual pkg - providers.append(pkg) - return providers + return list(providers) + + for provides, providesver, version in vp.provides_list: + pkg = version.parent_pkg + if not candidate_only or (version == get_candidate_ver(pkg)): + try: + providers.add(self._weakref[pkg.name]) + except KeyError: + package = self._weakref[pkg.name] = Package(self, pkg) + providers.add(package) + return list(providers) @deprecated_args def update(self, fetch_progress=None, pulse_interval=0, diff --git a/debian/changelog b/debian/changelog index f3e33d7b..c79ede07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low * apt/cache.py: - Make Cache.get_changes() much (~35x) faster (Closes: #578074). - Make Cache.req_reinstall_pkgs much faster as well. + - Make Cache.get_providing_packages() about 1000 times faster. * apt/package.py: - Decode using utf-8 in installed_files (LP: #407953). - Fix fetch_source() to work when source name = binary name (LP: #552400). |
