diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-06-01 13:10:55 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-06-01 13:10:55 +0000 |
| commit | a0596d73510acae4749480c209e0f318852fc83f (patch) | |
| tree | 8b699c3438f17547114172aa262da129e5b5ba2f /apt/cache.py | |
| parent | e451655d9d837fcc5ade3d336012f2bb04700c56 (diff) | |
| download | python-apt-a0596d73510acae4749480c209e0f318852fc83f.tar.gz | |
* Cache.GetChanges() added, support for Marked{Downgrade,Reinstall} tests added
Diffstat (limited to 'apt/cache.py')
| -rw-r--r-- | apt/cache.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/apt/cache.py b/apt/cache.py index 39af9327..2b3e8ace 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -4,9 +4,9 @@ from UserDict import UserDict class Cache(object): def __init__(self, progress=None): - self.open(progress) + self.Open(progress) - def open(self, progress): + def Open(self, progress): self._cache = apt_pkg.GetCache(progress) self._depcache = apt_pkg.GetDepCache(self._cache) self._records = apt_pkg.GetPkgRecords(self._cache) @@ -34,6 +34,15 @@ class Cache(object): def keys(self): return self._dict.keys() + def GetChanges(self): + changes = [] + for name in self._dict.keys(): + p = self._dict[name] + if p.MarkedUpgrade() or p.MarkedInstall() or p.MarkedDelete() or \ + p.MarkedDowngrade() or p.MarkedReinstall(): + changes.append(p) + return changes + def Upgrade(self, DistUpgrade=False): self._depcache.Upgrade(DistUpgrade) @@ -54,6 +63,9 @@ class MarkedChangesFilter(Filter): return False class FilteredCache(Cache): + def __init__(self): + Cache.__init__(self) + self._filtered = {} def __len__(self): return len(self._filtered) @@ -87,7 +99,11 @@ if __name__ == "__main__": for pkg in c.keys(): x= c[pkg].Name() + c.Upgrade() + for p in c.GetChanges(): + print p.Name() + print "Testing filtered cache" c = FilteredCache() c.Upgrade() c.AddFilter(MarkedChangesFilter()) |
