diff options
| -rw-r--r-- | debian/changelog | 7 | ||||
| -rw-r--r-- | doc/examples/acquire.py | 7 | ||||
| -rw-r--r-- | python/acquire.cc | 67 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 1 | ||||
| -rw-r--r-- | python/apt_pkgmodule.h | 1 |
5 files changed, 83 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index efd6cdca..402ff2dc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.16) unstable; urgency=low + + * added GetPkgAcqFile to queue individual file downloads with the + system + + -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 1 Dec 2005 14:01:39 +0100 + python-apt (0.6.15) unstable; urgency=low * rewrote cache.Commit() and make it raise proper Exception if stuff diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 72d0c74e..2736ad9c 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -34,6 +34,13 @@ pm = apt_pkg.GetPackageManager(depcache) print pm print fetcher +af = apt_pkg.GetPkgAcqFile(fetcher, + uri="ftp://ftp.debian.org/debian/dists/README", + descr="sample descr", + destFile="/tmp/lala2") +fetcher.Run() +sys.exit(1) + pm.GetArchives(fetcher,list,recs) for item in fetcher.Items: diff --git a/python/acquire.cc b/python/acquire.cc index 2bcd94c1..03606ef2 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -208,4 +208,71 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) + +// pkgAcquireFile + +static PyObject *AcquireFileAttr(PyObject *Self,char *Name) +{ + pkgAcqFile *acqFile = GetCpp<pkgAcqFile*>(Self); + + PyErr_SetString(PyExc_AttributeError,Name); + return 0; +} + + + + +PyTypeObject PkgAcquireFileType = +{ + PyObject_HEAD_INIT(&PyType_Type) + 0, // ob_size + "pkgAcquireFile", // tp_name + sizeof(CppPyObject<pkgAcqFile*>),// tp_basicsize + 0, // tp_itemsize + // Methods + CppDealloc<pkgAcqFile*>, // tp_dealloc + 0, // tp_print + AcquireFileAttr, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash +}; + +PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) +{ + PyObject *pyfetcher; + char *uri, *md5, *descr, *shortDescr, *destDir, *destFile; + int size; + 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, + &PkgAcquireType, &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, // shortdescr + destDir, // destdir + destFile // destfile + ); + CppPyObject<pkgAcqFile*> *AcqFileObj = CppPyObject_NEW<pkgAcqFile*>(&PkgAcquireFileType); + AcqFileObj->Object = af; + + return AcqFileObj; +} + + /*}}}*/ diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 5731cae4..e73628c3 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -398,6 +398,7 @@ static PyMethodDef methods[] = // Acquire {"GetAcquire",GetAcquire,METH_VARARGS,"GetAcquire() -> Acquire"}, + {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS,"GetPkgAcquireFile() -> pkgAcquireFile"}, // PkgManager {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager() -> PackageManager"}, diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 93112f89..84b0069f 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -75,6 +75,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args); // acquire extern PyTypeObject PkgAcquireType; PyObject *GetAcquire(PyObject *Self,PyObject *Args); +PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject *kwds); // packagemanager extern PyTypeObject PkgManagerType; |
