Commit 044322b4 authored by Julian Andres Klode's avatar Julian Andres Klode

Remove old API compatibility C++ support code

parent 14086582
#!/usr/bin/make -f
# Should be include-links, but that somehow fails.
export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
# For compatibility, add -DCOMPAT_0_7
export CFLAGS=-Wno-write-strings
export PATH := $(CURDIR)/utils:$(PATH)
export pyversions := $(CURDIR)/utils/pyversions
......
......@@ -320,41 +320,3 @@ PyTypeObject PyAcquireFile_Type = {
acquirefile_new, // tp_new
};
#ifdef COMPAT_0_7
char *doc_GetPkgAcqFile =
"GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n";
PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgAcqFile() is "
"deprecated. Please see apt_pkg.AcquireFile() for the "
"replacement", 1);
PyObject *pyfetcher;
char *uri, *md5, *descr, *shortDescr, *destDir, *destFile;
int size = 0;
uri = md5 = descr = shortDescr = destDir = destFile = "";
char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortDescr",
"destDir", "destFile", NULL
};
if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist,
&PyAcquire_Type, &pyfetcher, &uri, &md5,
&size, &descr, &shortDescr, &destDir, &destFile) == 0)
return 0;
pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyfetcher);
pkgAcqFile *af = new pkgAcqFile(fetcher, // owner
uri, // uri
md5, // md5
size, // size
descr, // descr
shortDescr,
destDir,
destFile); // short-desc
CppPyObject<pkgAcqFile*> *AcqFileObj = CppPyObject_NEW<pkgAcqFile*>(NULL, &PyAcquireFile_Type);
AcqFileObj->Object = af;
AcqFileObj->NoDelete = true;
return AcqFileObj;
}
#endif
......@@ -400,12 +400,4 @@ PyTypeObject PyAcquire_Type = {
PkgAcquireNew, // tp_new
};
#ifdef COMPAT_0_7
PyObject *GetAcquire(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated."
" Please see apt_pkg.Acquire() for the replacement.", 1);
return PkgAcquireNew(&PyAcquire_Type,Args,0);
}
#endif
......@@ -23,148 +23,7 @@
#include <Python.h>
/*}}}*/
#ifdef COMPAT_0_7
// debExtractControl - Exctract an arbitary control member /*{{{*/
// ---------------------------------------------------------------------
/* This is a common operation so this function will stay, but others that
expose the full range of the apt-inst .deb processing will join it some
day. */
static char *doc_debExtractControl =
"deb_extract_control(file[,member]) -> String\n"
"Returns the indicated file from the control tar. The default is 'control'\n";
static PyObject *debExtractControl(PyObject *Self,PyObject *Args)
{
char *Member = "control";
PyObject *File;
if (PyArg_ParseTuple(Args,"O|s",&File,&Member) == 0)
return 0;
// Subscope makes sure any clean up errors are properly handled.
PyObject *Res = 0;
{
// Open the file and associate the .deb
int fileno = PyObject_AsFileDescriptor(File);
if (fileno == -1)
return 0;
FileFd Fd(fileno,false);
debDebFile Deb(Fd);
if (_error->PendingError() == true)
return HandleErrors();
debDebFile::MemControlExtract Extract(Member);
if (Extract.Read(Deb) == false)
return HandleErrors();
// Build the return result
if (Extract.Control == 0)
{
Py_INCREF(Py_None);
Res = Py_None;
}
else
Res = PyString_FromStringAndSize(Extract.Control,Extract.Length+2);
}
return HandleErrors(Res);
}
/*}}}*/
// debExtractArchive - Exctract the archive /*{{{*/
// ---------------------------------------------------------------------
static char *doc_debExtractArchive =
"deb_extract_archive(File,rootdir) -> Bool\n"
"Extracts the Archive into the given root dir";
static PyObject *debExtractArchive(PyObject *Self,PyObject *Args)
{
char *Rootdir = NULL;
char cwd[512];
PyObject *File;
if (PyArg_ParseTuple(Args,"O|s",&File,&Rootdir) == 0)
return 0;
// Subscope makes sure any clean up errors are properly handled.
bool res = false;
{
if(Rootdir != NULL)
{
getcwd(cwd, sizeof(cwd));
chdir(Rootdir);
}
// Open the file and associate the .deb
int fileno = PyObject_AsFileDescriptor(File);
if (fileno == -1)
return 0;
FileFd Fd(fileno,false);
debDebFile Deb(Fd);
if (_error->PendingError() == true) {
if (Rootdir != NULL)
chdir (cwd);
return HandleErrors();
}
// extracts relative to the current dir
pkgDirStream Extract;
res = Deb.ExtractArchive(Extract);
if (Rootdir != NULL)
chdir (cwd);
if (res == false)
return HandleErrors(PyBool_FromLong(res));
}
return HandleErrors(PyBool_FromLong(res));
}
/*}}}*/
// arFindMember - Find member in AR archive /*{{{*/
// ---------------------------------------------------------------------
static char *doc_arCheckMember =
"ar_check_member(file, membername) -> Bool\n";
static PyObject *arCheckMember(PyObject *Self,PyObject *Args)
{
char *Member = NULL;
bool res = false;
PyObject *File;
if (PyArg_ParseTuple(Args,"Os",&File,&Member) == 0)
return 0;
// Open the file and associate the .deb
int fileno = PyObject_AsFileDescriptor(File);
if (fileno == -1)
return 0;
FileFd Fd(fileno,false);
ARArchive AR(Fd);
if (_error->PendingError() == true)
return HandleErrors();
if(AR.FindMember(Member) != 0)
res = true;
return HandleErrors(PyBool_FromLong(res));
}
/*}}}*/
// initapt_inst - Core Module Initialization /*{{{*/
// ---------------------------------------------------------------------
/* */
static PyMethodDef methods[] =
{
// access to ar files
{"arCheckMember", arCheckMember, METH_VARARGS, doc_arCheckMember},
// access to deb files
{"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl},
{"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive},
// access to tar streams
{"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract},
{"debExtract",debExtract,METH_VARARGS,doc_debExtract},
{}
};
#else
static PyMethodDef *methods = 0;
#endif // defined(COMPAT_0_7)
static const char *apt_inst_doc =
......
......@@ -14,12 +14,6 @@
#include "generic.h"
#include <apt-pkg/extracttar.h>
#ifdef COMPAT_0_7
PyObject *debExtract(PyObject *Self,PyObject *Args);
extern char *doc_debExtract;
PyObject *tarExtract(PyObject *Self,PyObject *Args);
extern char *doc_tarExtract;
#endif
extern PyTypeObject PyArMember_Type;
extern PyTypeObject PyArArchive_Type;
......
This diff is collapsed.
......@@ -161,63 +161,10 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args)
return HandleErrors(PyRes);
}
#ifdef COMPAT_0_7
static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Close() is deprecated, "
"because it causes segfaults. Delete the Cache instead.", 1);
PyObject *CacheFilePy = GetOwner<pkgCache*>(Self);
pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy);
Cache->Close();
Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Open() is deprecated, "
"because it causes memory leaks. Create a new Cache instead.",
1);
PyObject *CacheFilePy = GetOwner<pkgCache*>(Self);
pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy);
PyObject *pyCallbackInst = 0;
if (PyArg_ParseTuple(Args, "|O", &pyCallbackInst) == 0)
return 0;
if(pyCallbackInst != 0) {
PyOpProgress progress;
progress.setCallbackInst(pyCallbackInst);
if (Cache->Open(progress,false) == false)
return HandleErrors();
} else {
OpTextProgress Prog;
if (Cache->Open(Prog,false) == false)
return HandleErrors();
}
//std::cout << "new cache is " << (pkgCache*)(*Cache) << std::endl;
// ensure that the states are correct (LP: #659438)
pkgApplyStatus(*Cache);
// update the cache pointer after the cache was rebuild
((CppPyObject<pkgCache*> *)Self)->Object = (pkgCache*)(*Cache);
Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
#endif
static PyMethodDef PkgCacheMethods[] =
{
{"update",PkgCacheUpdate,METH_VARARGS,cache_update_doc},
#ifdef COMPAT_0_7
{"Open", PkgCacheOpen, METH_VARARGS,
"Open the cache; deprecated and unsafe"},
{"Close", PkgCacheClose, METH_VARARGS,"Close the cache"},
#endif
{}
};
......@@ -1654,11 +1601,3 @@ PyTypeObject PyDependencyList_Type =
/*}}}*/
#ifdef COMPAT_0_7
PyObject *TmpGetCache(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. "
"Please see apt_pkg.Cache() for the replacement.", 1);
return PkgCacheNew(&PyCache_Type,Args,0);
}
#endif
......@@ -78,38 +78,10 @@ static PyObject *cdrom_ident(PyObject *Self,PyObject *Args)
}
}
#ifdef COMPAT_0_7
static PyObject *cdrom_ident_old(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "Method 'Ident' of the "
"'apt_pkg.Cdrom' object is deprecated, use 'ident' instead.",
1);
pkgCdrom &Cdrom = GetCpp<pkgCdrom>(Self);
PyObject *pyCdromProgressInst = 0;
if (PyArg_ParseTuple(Args, "O", &pyCdromProgressInst) == 0) {
return 0;
}
PyCdromProgress progress;
progress.setCallbackInst(pyCdromProgressInst);
std::string ident;
bool res = Cdrom.Ident(ident, &progress);
PyObject *boolres = PyBool_FromLong(res);
PyObject *result = Py_BuildValue("(Os)", boolres, ident.c_str());
return HandleErrors(result);
}
#endif
static PyMethodDef cdrom_methods[] = {
{"add",cdrom_add,METH_VARARGS,cdrom_add_doc},
{"ident",cdrom_ident,METH_VARARGS,cdrom_ident_doc},
#ifdef COMPAT_0_7
{"Ident",cdrom_ident_old,METH_VARARGS,"DEPRECATED. DO NOT USE"},
#endif
{}
};
......@@ -165,11 +137,3 @@ PyTypeObject PyCdrom_Type = {
cdrom_new, // tp_new
};
#ifdef COMPAT_0_7
PyObject *GetCdrom(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. "
"Please see apt_pkg.Cdrom() for the replacement.", 1);
return cdrom_new(&PyCdrom_Type,Args,0);
}
#endif
......@@ -794,14 +794,6 @@ PyTypeObject PyDepCache_Type =
PkgDepCacheNew, // tp_new
};
#ifdef COMPAT_0_7
PyObject *GetDepCache(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated"
". Please see apt_pkg.DepCache() for the replacement.",1);
return PkgDepCacheNew(&PyDepCache_Type,Args,0);
}
#endif
......@@ -829,14 +821,6 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec
return PkgProblemResolverPyObj;
}
#ifdef COMPAT_0_7
PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) {
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is"
" deprecated. Please see apt_pkg.ProblemResolver() for the "
"replacement.", 1);
return PkgProblemResolverNew(&PyProblemResolver_Type,Args,0);
}
#endif
static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args)
{
......@@ -1121,15 +1105,6 @@ PyTypeObject PyActionGroup_Type =
PkgActionGroupNew, // tp_new
};
#ifdef COMPAT_0_7
PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is "
"deprecated. Please see apt_pkg.ActionGroup() for the "
"replacement.", 1);
return PkgActionGroupNew(&PyActionGroup_Type,Args,0);
}
#endif
/*}}}*/
......@@ -49,75 +49,6 @@ PyObject *HandleErrors(PyObject *Res)
return 0;
}
# ifdef COMPAT_0_7
// Helpers for deprecation.
// Given the name of the old attribute, return the name of the new attribute
// in a PyObject.
static PyObject *_PyApt_NewNameForAttribute(const char *attr) {
// Some exceptions from the standard algorithm.
if (strcasecmp(attr, "FileName") == 0) return PyString_FromString("filename");
if (strcasecmp(attr, "DestFile") == 0) return PyString_FromString("destfile");
if (strcasecmp(attr, "FileSize") == 0) return PyString_FromString("filesize");
if (strcasecmp(attr, "SubTree") == 0) return PyString_FromString("subtree");
if (strcasecmp(attr, "ReadPinFile") == 0) return PyString_FromString("read_pinfile");
if (strcasecmp(attr, "SetReInstall") == 0) return PyString_FromString("set_reinstall");
if (strcasecmp(attr, "URI") == 0) return PyString_FromString("uri");
if (strcasecmp(attr, "ArchiveURI") == 0) return PyString_FromString("archive_uri");
if (strcasecmp(attr, "MD5Hash") == 0) return PyString_FromString("md5_hash");
if (strcasecmp(attr, "SHA1Hash") == 0) return PyString_FromString("sha1_hash");
if (strcasecmp(attr, "SHA256Hash") == 0) return PyString_FromString("sha256_hash");
if (strcasecmp(attr, "UntranslatedDepType") == 0) return PyString_FromString("dep_type_untranslated");
size_t attrlen = strlen(attr);
// Reserve the old name + 5, this should reduce resize to a minimum.
string new_name;
new_name.reserve(attrlen + 5);
for(unsigned int i=0; i < attrlen; i++) {
// Replace all uppercase ASCII characters with their lower-case ones.
if (attr[i] > 64 && attr[i] < 91) {
if (i > 0)
new_name += "_";
new_name += attr[i] + 32;
} else {
new_name += attr[i];
}
}
return CppPyString(new_name);
}
// Handle deprecated attributes by setting a warning and returning the new
// attribute.
PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr) {
PyObject *value = PyObject_GenericGetAttr(self, attr);
if (value == NULL) {
PyObject *ptype, *pvalue, *ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
const char *attrname = PyObject_AsString(attr);
PyObject *newattr = _PyApt_NewNameForAttribute(attrname);
value = PyObject_GenericGetAttr(self, newattr);
if (value != NULL) {
const char *newattrname = PyString_AsString(newattr);
const char *cls = self->ob_type->tp_name;
char *warning_string = new char[strlen(newattrname) + strlen(cls) +
strlen(attrname) + 66];
sprintf(warning_string, "Attribute '%s' of the '%s' object is "
"deprecated, use '%s' instead.", attrname, cls, newattrname);
PyErr_WarnEx(PyExc_DeprecationWarning, warning_string, 1);
delete[] warning_string;
} else {
Py_XINCREF(ptype);
Py_XINCREF(pvalue);
Py_XINCREF(ptraceback);
PyErr_Restore(ptype, pvalue, ptraceback);
}
Py_DECREF(newattr);
Py_XDECREF(ptype);
Py_XDECREF(pvalue);
Py_XDECREF(ptraceback);
}
return value;
}
# endif //COMPAT_0_7
/*}}}*/
// ListToCharChar - Convert a list to an array of char char /*{{{*/
// ---------------------------------------------------------------------
......
......@@ -58,8 +58,6 @@ typedef int Py_ssize_t;
#define PyInt_Check PyLong_Check
#define PyInt_AsLong PyLong_AsLong
#define PyInt_FromLong PyLong_FromLong
// Force 0.7 compatibility to be off in Python 3 builds
#undef COMPAT_0_7
#else
// Compatibility for Python 2.5 and previous.
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 5)
......@@ -251,10 +249,6 @@ inline PyObject *MkPyNumber(char o) { return PyInt_FromLong(o); }
inline PyObject *MkPyNumber(double o) { return PyFloat_FromDouble(o); }
# ifdef COMPAT_0_7
PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr);
# else
# define _PyAptObject_getattro 0
# endif
#endif
......@@ -225,15 +225,6 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
return PkgManagerObj;
}
#ifdef COMPAT_0_7
PyObject *GetPkgManager(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is "
"deprecated. Please see apt_pkg.PackageManager() for the "
"replacement.", 1);
return PkgManagerNew(&PyPackageManager2_Type,Args,0);
}
#endif
static PyObject *PkgManagerInstall(PyObject *Self,PyObject *Args)
{
......
......@@ -218,12 +218,3 @@ PyTypeObject PyPackageRecords_Type =
/*}}}*/
#ifdef COMPAT_0_7
PyObject *GetPkgRecords(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is "
"deprecated. Please see apt_pkg.Records() for the "
"replacement.", 1);
return PkgRecordsNew(&PyPackageRecords_Type,Args,0);
}
#endif
......@@ -205,29 +205,6 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) {
return Dict;
}
#ifdef COMPAT_0_7
static PyObject *PkgSrcRecordsGetBuildDepends_old(PyObject *Self,void*) {
PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends");
if (Struct.Last == 0)
return 0;
PyObject *List = PyList_New(0);
vector<pkgSrcRecords::Parser::BuildDepRec> bd;
if(!Struct.Last->BuildDepends(bd, false /* arch-only*/))
return NULL; // error
PyObject *v;
for(unsigned int i=0;i<bd.size();i++) {
v = Py_BuildValue("(ssNN)", bd[i].Package.c_str(),
bd[i].Version.c_str(),
MkPyNumber(bd[i].Op),
MkPyNumber(bd[i].Type));
PyList_Append(List, v);
Py_DECREF(v);
}
return List;
}
#endif
static PyGetSetDef PkgSrcRecordsGetSet[] = {
{"binaries",PkgSrcRecordsGetBinaries,0,
......@@ -251,9 +228,6 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = {
"The section of the source package."},
{"version",PkgSrcRecordsGetVersion,0,
"The version of the source package."},
#ifdef COMPAT_0_7
{"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."},
#endif
{}
};
......@@ -316,15 +290,3 @@ PyTypeObject PySourceRecords_Type =
/*}}}*/
#ifdef COMPAT_0_7
PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is "
"deprecated. Please see apt_pkg.SourceRecords() for the "
"replacement.", 1);
if (PyArg_ParseTuple(Args,"") == 0)
return 0;
return HandleErrors(CppPyObject_NEW<PkgSrcRecordsStruct>(NULL, &PySourceRecords_Type));
}
#endif
......@@ -95,15 +95,7 @@ void PyOpProgress::Update()
setattr(callbackInst, "subop", "s", SubOp.c_str());
setattr(callbackInst, "major_change", "b", MajorChange);
setattr(callbackInst, "percent", "N", MkPyNumber(Percent));
#ifdef COMPAT_0_7
setattr(callbackInst, "Op", "s", Op.c_str());
setattr(callbackInst, "subOp", "s", SubOp.c_str());
setattr(callbackInst, "majorChange", "b", MajorChange);
PyObject *arglist = Py_BuildValue("(N)", MkPyNumber(Percent));
RunSimpleCallback("update", arglist);
#else
RunSimpleCallback("update");
#endif
}
void PyOpProgress::Done()
......@@ -241,13 +233,6 @@ void PyFetchProgress::Start()
//std::cout << "Start" << std::endl;
pkgAcquireStatus::Start();
#ifdef COMPAT_0_7
setattr(callbackInst, "currentCPS", "N", MkPyNumber(0));
setattr(callbackInst, "currentBytes", "N", MkPyNumber(0));
setattr(callbackInst, "currentItems", "N", MkPyNumber(0));
setattr(callbackInst, "totalItems", "N", MkPyNumber(0));
setattr(callbackInst, "totalBytes", "N", MkPyNumber(0));
#endif
RunSimpleCallback("start");
/* After calling the start method we can safely allow
......@@ -314,106 +299,7 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner)
PyCbObj_BEGIN_ALLOW_THREADS
return true;
}
#ifdef COMPAT_0_7
setattr(callbackInst, "currentCPS", "N", MkPyNumber(CurrentCPS));
setattr(callbackInst, "currentBytes", "N", MkPyNumber(CurrentBytes));
setattr(callbackInst, "totalBytes", "N", MkPyNumber(TotalBytes));
setattr(callbackInst, "fetchedBytes", "N", MkPyNumber(FetchedBytes));
setattr(callbackInst, "currentItems", "N", MkPyNumber(CurrentItems));
setattr(callbackInst, "totalItems", "N", MkPyNumber(TotalItems));
// Go through the list of items and add active items to the
// activeItems vector.
map<pkgAcquire::Worker *, pkgAcquire::ItemDesc *> activeItemMap;
for(pkgAcquire::Worker *Worker = Owner->WorkersBegin();
Worker != 0; Worker = Owner->WorkerStep(Worker)) {
if (Worker->CurrentItem == 0) {
// Ignore workers with no item running
continue;
}
activeItemMap.insert(std::make_pair(Worker, Worker->CurrentItem));
}
// Create the tuple that is passed as argument to pulse().
// This tuple contains activeItemMap.size() item tuples.
PyObject *arglist;
if (((int)activeItemMap.size()) > 0) {
PyObject *itemsTuple = PyTuple_New((Py_ssize_t) activeItemMap.size());
// Go through activeItems, create an item tuple in the form
// (URI, Description, ShortDesc, FileSize, PartialSize) and
// add that tuple to itemsTuple.
map<pkgAcquire::Worker *, pkgAcquire::ItemDesc *>::iterator iter;
int tuplePos;
for(tuplePos = 0, iter = activeItemMap.begin();
iter != activeItemMap.end(); ++iter, tuplePos++) {
pkgAcquire::Worker *worker = iter->first;
pkgAcquire::ItemDesc *itm = iter->second;
PyObject *itmTuple = Py_BuildValue("(sssNN)", itm->URI.c_str(),
itm->Description.c_str(),
itm->ShortDesc.c_str(),
MkPyNumber(worker->TotalSize),
MkPyNumber(worker->CurrentSize));
PyTuple_SetItem(itemsTuple, tuplePos, itmTuple);
}
// Now our itemsTuple is ready for being passed to pulse().
// pulse() is going to receive a single argument, being the
// tuple of items, which again contains one tuple with item
// information per item.
//
// Python Example:
//
// class MyFetchProgress(FetchProgress):
// def pulse(self, items):
// for itm in items:
// uri, desc, shortdesc, filesize, partialsize = itm
//
arglist = PyTuple_Pack(1, itemsTuple);
}
else {
arglist = Py_BuildValue("(())");
}
PyObject *result;
bool res = true;
if (RunSimpleCallback("pulse_items", arglist, &result)) {
if (result != NULL && PyArg_Parse(result, "b", &res) && res == false) {
// the user returned a explicit false here, stop
PyCbObj_BEGIN_ALLOW_THREADS
return false;
}
}
arglist = Py_BuildValue("()");
if (!RunSimpleCallback("pulse", arglist, &result)) {
PyCbObj_BEGIN_ALLOW_THREADS
return true;
}
if((result == NULL) || (!PyArg_Parse(result, "b", &res)))
{
// most of the time the user who subclasses the pulse()
// method forgot to add a return {True,False} so we just
// assume he wants a True. There may be a Python exception on the stack
// that must be cleared.
PyErr_Clear();
PyCbObj_BEGIN_ALLOW_THREADS
return true;
}
PyCbObj_BEGIN_ALLOW_THREADS
// fetching can be canceld by returning false
return res;
#else
return false;
#endif
}
......@@ -548,9 +434,6 @@ void PyCdromProgress::Update(std::string text, int current)
{
PyObject *arglist = Py_BuildValue("(si)", text.c_str(), current);
setattr(callbackInst, "total_steps", "i", totalSteps);
#ifdef COMPAT_0_7
setattr(callbackInst, "totalSteps", "i", totalSteps);
#endif
RunSimpleCallback("update", arglist);
}
......
......@@ -168,12 +168,3 @@ PyTypeObject PySourceList_Type =
PkgSourceListNew, // tp_new
};
#ifdef COMPAT_0_7