diff options
| author | Sebastian Heinlein <sebi@glatzor.de> | 2008-08-21 18:34:41 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@glatzor.de> | 2008-08-21 18:34:41 +0200 |
| commit | 312c6465f3ac7da68c610a01b4856cb45ae62b34 (patch) | |
| tree | 80ea9224428ccadbd29f7487cddfd3b9698f2179 | |
| parent | 1db0459ae3a8a2240ffb9585bb1c378d7b17acbb (diff) | |
| download | python-apt-312c6465f3ac7da68c610a01b4856cb45ae62b34.tar.gz | |
Add apt.cache.Cache.isVirtualPackage() and apt.cache.Cache.getProvidingPackages() - taken from GDebi.
| -rw-r--r-- | apt/cache.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/apt/cache.py b/apt/cache.py index 3df2b4a6..e59e30c3 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -182,6 +182,51 @@ class Cache(object): finally: os.close(lock) + def isVirtualPackage(self, name): + """ + Return True if the package of the given name is a virtual package + """ + try: + virtual_pkg = self._cache[name] + except KeyError: + return False + if len(virtual_pkg.VersionList) == 0: + return True + return False + + def getProvidingPackages(self, virtual): + """ + Return a list of packages which provide the virtual package of the + specified name + """ + providers = [] + try: + vp = self._cache[virtual] + if len(vp.VersionList) != 0: + return providers + except IndexError: + return providers + for pkg in self: + v = self._depcache.GetCandidateVer(pkg._pkg) + if v == None: + continue + for p in v.ProvidesList: + #print virtual + #print p[0] + if virtual == p[0]: + # we found a pkg that provides this virtual + # pkg, check if the proivdes is any good + providers.append(pkg) + #cand = self._cache[pkg.name] + #candver = self._cache._depcache.GetCandidateVer(cand._pkg) + #instver = cand._pkg.CurrentVer + #res = apt_pkg.CheckDep(candver.VerStr,oper,ver) + #if res == True: + # self._dbg(1,"we can use %s" % pkg.name) + # or_found = True + # break + return providers + def update(self, fetchProgress=None): " run the equivalent of apt-get update " lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" |
