summaryrefslogtreecommitdiff
path: root/python/depcache.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-03-31 18:30:03 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-03-31 18:30:03 +0000
commit65fc206205e13da3fab7438dcb4501231f6f88ac (patch)
tree44d6f2659debf9d35a2acf2fac92aacbc3f0174a /python/depcache.cc
parent67b5de8d0564a0f349766ffa26ffbcc5a6fdab6e (diff)
downloadpython-apt-65fc206205e13da3fab7438dcb4501231f6f88ac.tar.gz
* merged with the pkgDepCache tree
Patches applied: * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-10 * version number is 0.5.36ubuntu1 * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-11 * return "None" in GetCandidateVer if no Candidate is found * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-12 * changelog entry * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-13 * never do "DepCache.Init()" implicit * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-14 * reference counting added for Py_None
Diffstat (limited to 'python/depcache.cc')
-rw-r--r--python/depcache.cc31
1 files changed, 14 insertions, 17 deletions
diff --git a/python/depcache.cc b/python/depcache.cc
index 9c302b40..dcccf75c 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -21,7 +21,6 @@
#include <iostream>
#include "progress.h"
-#include "cache.h"
// DepCache Class /*{{{*/
// ---------------------------------------------------------------------
@@ -62,6 +61,7 @@ static PyObject *PkgDepCacheInit(PyObject *Self,PyObject *Args)
Struct.depcache->Init(0);
}
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -75,6 +75,10 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
pkgCache::VerIterator I = Struct.depcache->GetCandidateVer(Pkg);
+ if(I.end()) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
CandidateObj = CppOwnedPyObject_NEW<pkgCache::VerIterator>(PackageObj,&VersionType,I);
return CandidateObj;
@@ -93,6 +97,7 @@ static PyObject *PkgDepCacheUpgrade(PyObject *Self,PyObject *Args)
else
pkgAllUpgrade(*Struct.depcache);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -104,11 +109,12 @@ static PyObject *PkgDepCacheReadPinFile(PyObject *Self,PyObject *Args)
if (PyArg_ParseTuple(Args,"|s",&file) == 0)
return 0;
- if(file == NULL)
+ if(file == NULL)
ReadPinFile(*Struct.policy);
else
ReadPinFile(*Struct.policy, file);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -122,6 +128,7 @@ static PyObject *PkgDepCacheFixBroken(PyObject *Self,PyObject *Args)
pkgFixBroken(*Struct.depcache);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -137,6 +144,7 @@ static PyObject *PkgDepCacheMarkKeep(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
Struct.depcache->MarkKeep(Pkg);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -152,6 +160,7 @@ static PyObject *PkgDepCacheMarkDelete(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
Struct.depcache->MarkDelete(Pkg,purge);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -166,6 +175,7 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
Struct.depcache->MarkInstall(Pkg);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -296,12 +306,8 @@ static PyObject *DepCacheAttr(PyObject *Self,char *Name)
{
PkgDepCacheStruct &Struct = GetCpp<PkgDepCacheStruct>(Self);
- // look like a cache
- if (strcmp("Packages",Name) == 0)
- return CppOwnedPyObject_NEW<PkgListStruct>(Self,&PkgListType,
- Struct.depcache->PkgBegin());
// size querries
- else if(strcmp("KeepCount",Name) == 0)
+ if(strcmp("KeepCount",Name) == 0)
return Py_BuildValue("l", Struct.depcache->KeepCount());
else if(strcmp("InstCount",Name) == 0)
return Py_BuildValue("l", Struct.depcache->InstCount());
@@ -345,8 +351,7 @@ PyTypeObject PkgDepCacheType =
PyObject *GetDepCache(PyObject *Self,PyObject *Args)
{
PyObject *Owner;
- PyObject *pyCallbackInst = 0;
- if (PyArg_ParseTuple(Args,"O!|O",&PkgCacheType,&Owner,&pyCallbackInst) == 0)
+ if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0)
return 0;
PyObject *DepCachePyObj;
@@ -356,14 +361,6 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args)
HandleErrors(DepCachePyObj);
PkgDepCacheStruct &Struct = GetCpp<PkgDepCacheStruct>(DepCachePyObj);
- if(pyCallbackInst != 0) {
- PyOpProgress progress;
- progress.setCallbackInst(pyCallbackInst);
- Struct.depcache->Init(&progress);
- } else {
- Struct.depcache->Init(0);
- }
-
return DepCachePyObj;
}