summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-05-09 13:02:19 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-05-09 13:02:19 +0000
commitf637fdcce22f31ed51a12b860ada598286180bdb (patch)
tree196aaa8d0b88e35c4d860efd41cc9e6347dd8a82
parentae3f10fba648644a568dab3e21480580eb21e8a1 (diff)
downloadpython-apt-f637fdcce22f31ed51a12b860ada598286180bdb.tar.gz
* only import stuff into the cache that has at least one version
-rw-r--r--apt/cache.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/apt/cache.py b/apt/cache.py
index e575745f..2dac0739 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -10,10 +10,9 @@ class Filter(object):
class Cache(object):
def __init__(self):
- #dict.__init__(self)
self.open()
- def open(self)
+ def open(self):
self._cache = apt_pkg.GetCache()
self._depcache = apt_pkg.GetDepCache(self._cache)
self._records = apt_pkg.GetPkgRecords(self._cache)
@@ -22,7 +21,9 @@ class Cache(object):
# build the packages dict
for pkg in self._cache.Packages:
- self._dict[pkg.Name] = Package(self._cache, self._depcache, self._records, pkg)
+ # drop stuff with no versions (cruft)
+ if len(pkg.VersionList) > 0:
+ self._dict[pkg.Name] = Package(self._cache, self._depcache, self._records, pkg)
def __getitem__(self, key):
return self._dict[key]
@@ -46,7 +47,6 @@ class Cache(object):
def Commit(self, fprogress, iprogress):
self._depcache.Commit(fprogress, iprogress)
- def
if __name__ == "__main__":
print "Cache self test"
@@ -55,6 +55,7 @@ if __name__ == "__main__":
print c.has_key("aptitudex")
p = c["aptitude"]
print p.Name()
+ print len(c)
for pkg in c.keys():
x= c[pkg].Name()