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 | |
| parent | e451655d9d837fcc5ade3d336012f2bb04700c56 (diff) | |
| download | python-apt-a0596d73510acae4749480c209e0f318852fc83f.tar.gz | |
* Cache.GetChanges() added, support for Marked{Downgrade,Reinstall} tests added
| -rw-r--r-- | apt/cache.py | 20 | ||||
| -rw-r--r-- | apt/package.py | 4 | ||||
| -rw-r--r-- | debian/changelog | 9 | ||||
| -rw-r--r-- | python/depcache.cc | 33 |
4 files changed, 63 insertions, 3 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()) diff --git a/apt/package.py b/apt/package.py index b4f6b1df..4d1db55d 100644 --- a/apt/package.py +++ b/apt/package.py @@ -101,6 +101,10 @@ class Package(object): return self._depcache.MarkedDelete(self._pkg) def MarkedKeep(self): return self._depcache.MarkedKeep(self._pkg) + def MarkedDowngrade(self): + return self._depcache.MarkedDowngrade(self._pkg) + def MarkedReinstall(self): + return self._depcache.MarkedReinstall(self._pkg) def IsInstalled(self): return (self._pkg.CurrentVer != None) def IsUpgradable(self): diff --git a/debian/changelog b/debian/changelog index 2541278b..294fab09 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,11 @@ -python-apt (0.6.12ubuntu1) experimental; urgency=low +python-apt (0.6.13) breezy; urgency=low + + * support for Marked{Downgrade,Reinstall} added + * Cache.GetChanges() added + + -- Michael Vogt <michael.vogt@ubuntu.com> Wed, 1 Jun 2005 14:57:57 +0200 + +python-apt (0.6.12ubuntu1) breezy; urgency=low * Greek0@gmx.net--2005-main/python-apt--debian--0.6: - python2.{3,4}-apt conflicts with python-apt (<< 0.6.11) diff --git a/python/depcache.cc b/python/depcache.cc index 7ecdd508..b7ed98ac 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -403,6 +403,37 @@ static PyObject *PkgDepCacheMarkedKeep(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("b",state.Keep())); } +static PyObject *PkgDepCacheMarkedDowngrade(PyObject *Self,PyObject *Args) +{ + pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); + + PyObject *PackageObj; + if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + return 0; + + pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); + pkgDepCache::StateCache &state = (*depcache)[Pkg]; + + return HandleErrors(Py_BuildValue("b",state.Downgrade())); +} + +static PyObject *PkgDepCacheMarkedReinstall(PyObject *Self,PyObject *Args) +{ + pkgDepCache *depcache = GetCpp<pkgDepCache *>(Self); + + PyObject *PackageObj; + if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + return 0; + + pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); + pkgDepCache::StateCache &state = (*depcache)[Pkg]; + + bool res = state.Install() && (state.iFlags & pkgDepCache::ReInstall); + + return HandleErrors(Py_BuildValue("b",res)); +} + + static PyMethodDef PkgDepCacheMethods[] = { {"Init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"}, @@ -424,6 +455,8 @@ static PyMethodDef PkgDepCacheMethods[] = {"MarkedUpgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"}, {"MarkedDelete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"}, {"MarkedKeep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"}, + {"MarkedReinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"}, + {"MarkedDowngrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"}, // Action {"Commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"}, |
