From fe5f0be5325814bebafed82867cc7b81ce0c82e2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 May 2006 16:39:11 +0200 Subject: * merged r189 from mainline --- python/tar.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/tar.cc b/python/tar.cc index 20fb1f5f..22c0327e 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -88,7 +88,7 @@ bool ProcessTar::DoItem(Item &Itm,int &Fd) // --------------------------------------------------------------------- /* */ char *doc_tarExtract = -"tarExtract(File,Func,Comp) -> None" +"tarExtract(File,Func,Comp) -> None\n" "The tar file referenced by the file object File, Func called for each\n" "Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n"; PyObject *tarExtract(PyObject *Self,PyObject *Args) @@ -128,7 +128,7 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args) // --------------------------------------------------------------------- /* */ char *doc_debExtract = -"debExtract(File,Func,Chunk) -> None" +"debExtract(File,Func,Chunk) -> None\n" "The deb referenced by the file object File is examined. The AR member\n" "given by Chunk is treated as a tar.gz and fed through Func like\n" "tarExtract\n"; -- cgit v1.2.3 From 6fc084d34105f336fdf090e2dd45e402e25cfc57 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 26 Jun 2006 10:11:25 +0200 Subject: * python/depcache.cc: - added "DepCache.IsGarbage" flag --- python/depcache.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python') diff --git a/python/depcache.cc b/python/depcache.cc index e8140e2b..60bbc1a4 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -370,6 +370,20 @@ static PyObject *PkgDepCacheIsUpgradable(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("b",state.Upgradable())); } +static PyObject *PkgDepCacheIsGarbage(PyObject *Self,PyObject *Args) +{ + pkgDepCache *depcache = GetCpp(Self); + + PyObject *PackageObj; + if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + return 0; + + pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); + pkgDepCache::StateCache &state = (*depcache)[Pkg]; + + return HandleErrors(Py_BuildValue("b",state.Garbage)); +} + static PyObject *PkgDepCacheIsNowBroken(PyObject *Self,PyObject *Args) { pkgDepCache *depcache = GetCpp(Self); @@ -507,6 +521,7 @@ static PyMethodDef PkgDepCacheMethods[] = {"IsUpgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, {"IsNowBroken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, {"IsInstBroken",PkgDepCacheIsInstBroken,METH_VARARGS,"Is pkg broken on the current install"}, + {"IsGarbage",PkgDepCacheIsGarbage,METH_VARARGS,"Is pkg garbage (mark-n-sweep)"}, {"MarkedInstall",PkgDepCacheMarkedInstall,METH_VARARGS,"Is pkg marked for install"}, {"MarkedUpgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"}, {"MarkedDelete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"}, -- cgit v1.2.3 From 88c410f794c968cd5c50fd7e9838036e4207b88c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 3 Aug 2006 17:00:32 +0200 Subject: * basic ddtp support added --- doc/examples/desc.py | 25 +++++++++++++++++++ python/cache.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 doc/examples/desc.py (limited to 'python') diff --git a/doc/examples/desc.py b/doc/examples/desc.py new file mode 100644 index 00000000..87b9473b --- /dev/null +++ b/doc/examples/desc.py @@ -0,0 +1,25 @@ + +import apt_pkg + +apt_pkg.init() + +apt_pkg.Config.Set("APT::Acquire::Translation","de") + +cache = apt_pkg.GetCache() +depcache = apt_pkg.GetDepCache(cache) + +pkg = cache["gcc"] +cand = depcache.GetCandidateVer(pkg) +print cand + +desc = cand.TranslatedDescription +print desc +print desc.FileList +(f,index) = desc.FileList.pop(0) + +records = apt_pkg.GetPkgRecords(cache) +records.Lookup((f,index)) +desc = records.LongDesc +print len(desc) +print desc + diff --git a/python/cache.cc b/python/cache.cc index 174423c2..15b63b35 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -443,6 +443,69 @@ PyTypeObject PackageType = 0, // tp_hash }; /*}}}*/ +// Description Class /*{{{*/ +// --------------------------------------------------------------------- +static PyObject *DescriptionAttr(PyObject *Self,char *Name) +{ + pkgCache::DescIterator &Desc = GetCpp(Self); + PyObject *Owner = GetOwner(Self); + + if (strcmp("LanguageCode",Name) == 0) + return PyString_FromString(Desc.LanguageCode()); + else if (strcmp("md5",Name) == 0) + return Safe_FromString(Desc.md5()); + else if (strcmp("FileList",Name) == 0) + { + /* The second value in the tuple is the index of the VF item. If the + user wants to request a lookup then that number will be used. + Maybe later it can become an object. */ + PyObject *List = PyList_New(0); + for (pkgCache::DescFileIterator I = Desc.FileList(); I.end() == false; I++) + { + PyObject *DescFile; + PyObject *Obj; + DescFile = CppOwnedPyObject_NEW(Owner,&PackageFileType,I.File()); + Obj = Py_BuildValue("Nl",DescFile,I.Index()); + PyList_Append(List,Obj); + Py_DECREF(Obj); + } + return List; + } + PyErr_SetString(PyExc_AttributeError,Name); + return 0; +} + +static PyObject *DescriptionRepr(PyObject *Self) +{ + pkgCache::DescIterator &Desc = GetCpp(Self); + + char S[300]; + snprintf(S,sizeof(S), + "), // tp_basicsize + 0, // tp_itemsize + // Methods + CppOwnedDealloc, // tp_dealloc + 0, // tp_print + DescriptionAttr, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + DescriptionRepr, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash +}; + /*}}}*/ // Version Class /*{{{*/ // --------------------------------------------------------------------- @@ -571,6 +634,11 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) return PyString_FromString(Ver.PriorityType()); else if (strcmp("Downloadable", Name) == 0) return Py_BuildValue("b", Ver.Downloadable()); + else if (strcmp("TranslatedDescription", Name) == 0) { + return CppOwnedPyObject_NEW(Owner, + &DescriptionType, + Ver.TranslatedDescription()); + } #if 0 // FIXME: enable once pkgSourceList is stored somewhere else if (strcmp("IsTrusted", Name) == 0) { @@ -625,6 +693,7 @@ PyTypeObject VersionType = }; /*}}}*/ + // PackageFile Class /*{{{*/ // --------------------------------------------------------------------- static PyObject *PackageFileAttr(PyObject *Self,char *Name) -- cgit v1.2.3 From 0d6bdd9d329f6527f6a5f2337828e03c2e2af508 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 6 Oct 2006 17:22:40 +0200 Subject: * python/depcache.cc: - suport for pkgActionGrup added --- debian/changelog | 2 +- python/depcache.cc | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index d9b428bd..b1099dea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,7 +10,7 @@ python-apt (0.6.19) unstable; urgency=low - fix commit doc string to also cite the open related callbacks - allow change of rootdir for APT database loading - -- + -- Michael Vogt Tue, 27 Jun 2006 16:51:56 +0200 python-apt (0.6.18) unstable; urgency=low diff --git a/python/depcache.cc b/python/depcache.cc index 60bbc1a4..159a7103 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -745,3 +745,73 @@ PyTypeObject PkgProblemResolverType = }; /*}}}*/ + +// pkgActionGroup Class /*{{{*/ +// --------------------------------------------------------------------- + + +static PyObject *PkgActionGroupRelease(PyObject *Self,PyObject *Args) +{ + pkgDepCache::ActionGroup *ag = GetCpp(Self); + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + ag->release(); + Py_INCREF(Py_None); + return HandleErrors(Py_None); +} + +static PyMethodDef PkgActionGroupMethods[] = +{ + {"release", PkgActionGroupRelease, METH_VARARGS, "release()"}, + {} +}; + + +static PyObject *ActionGroupAttr(PyObject *Self,char *Name) +{ + pkgDepCache::ActionGroup *ag = GetCpp(Self); + + return Py_FindMethod(PkgActionGroupMethods,Self,Name); +} + + +PyTypeObject PkgActionGroupType = +{ + PyObject_HEAD_INIT(&PyType_Type) + 0, // ob_size + "pkgActionGroup", // tp_name + sizeof(CppOwnedPyObject), // tp_basicsize + 0, // tp_itemsize + // Methods + CppOwnedDealloc, // tp_dealloc + 0, // tp_print + ActionGroupAttr, // 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 *GetPkgActionGroup(PyObject *Self,PyObject *Args) +{ + PyObject *Owner; + if (PyArg_ParseTuple(Args,"O!",&PkgDepCacheType,&Owner) == 0) + return 0; + + pkgDepCache *depcache = GetCpp(Owner); + pkgDepCache::ActionGroup *group = new pkgDepCache::ActionGroup(*depcache); + CppOwnedPyObject *PkgActionGroupPyObj; + PkgActionGroupPyObj = CppOwnedPyObject_NEW(Owner, + &PkgActionGroupType, + group); + HandleErrors(PkgActionGroupPyObj); + + return PkgActionGroupPyObj; + +} + + + /*}}}*/ -- cgit v1.2.3 From 590401a9f60b47f2fb39c5f3f42c70217ab4f50a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 6 Oct 2006 17:28:31 +0200 Subject: * python/apt_pkgmodule.cc: - *cough* expose the new PkgActionGroup stuff --- python/apt_pkgmodule.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'python') diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e73628c3..6bd79730 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -392,6 +392,7 @@ static PyMethodDef methods[] = // misc {"GetPkgProblemResolver",GetPkgProblemResolver,METH_VARARGS,"GetDepProblemResolver(DepCache) -> PkgProblemResolver"}, + {"GetPkgActionGroup",GetPkgActionGroup,METH_VARARGS,"GetPkgActionGroup(DepCache) -> PkgActionGroup"}, // Cdrom {"GetCdrom",GetCdrom,METH_VARARGS,"GetCdrom() -> Cdrom"}, -- cgit v1.2.3 From 5b3663b413e46ac6d4e8d9d394d1459859fd0eb1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 6 Oct 2006 17:34:48 +0200 Subject: * python/apt_pkgmodule.h: - do export PkgGetActionGroup --- python/apt_pkgmodule.h | 1 + 1 file changed, 1 insertion(+) (limited to 'python') diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index fe7dfe88..d58f4589 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -67,6 +67,7 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args); // pkgProblemResolver extern PyTypeObject PkgProblemResolverType; PyObject *GetPkgProblemResolver(PyObject *Self, PyObject *Args); +PyObject *GetPkgActionGroup(PyObject *Self, PyObject *Args); // cdrom extern PyTypeObject PkgCdromType; -- cgit v1.2.3 From 4a741085e3895d83aa3b0a522123a923b0a64aa4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 26 Jan 2007 17:20:29 +0100 Subject: * support "fromUser()" flag in apt.Package.markInstall() to make setting the automatic install information available --- apt/package.py | 5 +++-- python/depcache.cc | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'python') diff --git a/apt/package.py b/apt/package.py index 0d1145ea..f67ad6ce 100644 --- a/apt/package.py +++ b/apt/package.py @@ -290,12 +290,13 @@ class Package(object): Fix.InstallProtect() Fix.Resolve() self._pcache.cachePostChange() - def markInstall(self, autoFix=True, autoInst=True): + def markInstall(self, autoFix=True, autoInst=True, fromUser=True): """ mark a package for install. Run the resolver if autoFix is set, automatically install required dependencies if autoInst is set + record it as automatically installed when fromuser is set to false """ self._pcache.cachePreChange() - self._depcache.MarkInstall(self._pkg, autoInst) + self._depcache.MarkInstall(self._pkg, autoInst, fromUser) # try to fix broken stuff if autoFix and self._depcache.BrokenCount > 0: fixer = apt_pkg.GetPkgProblemResolver(self._depcache) diff --git a/python/depcache.cc b/python/depcache.cc index 159a7103..71e6a2e6 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -346,11 +346,13 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) PyObject *PackageObj; char autoInst=1; - if (PyArg_ParseTuple(Args,"O!|b",&PackageType,&PackageObj, &autoInst) == 0) + char fromUser=1; + if (PyArg_ParseTuple(Args,"O!|bb",&PackageType,&PackageObj, + &autoInst, &fromUser) == 0) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); - depcache->MarkInstall(Pkg, autoInst); + depcache->MarkInstall(Pkg, autoInst, 0, fromUser); Py_INCREF(Py_None); return HandleErrors(Py_None); -- cgit v1.2.3 From 1c878fca17aaa7d8300224e1aed0f13066fe3e84 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 22 Feb 2007 17:11:51 +0100 Subject: * apt/package.py: - handle invalid unicode more gracefully (LP#86215) * rebuild against latest apt --- apt/package.py | 7 ++++++- debian/changelog | 5 ++++- debian/control | 2 +- python/string.cc | 6 ++++-- 4 files changed, 15 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/apt/package.py b/apt/package.py index af5dd327..39e2993c 100644 --- a/apt/package.py +++ b/apt/package.py @@ -166,7 +166,12 @@ class Package(object): desc_iter = ver.TranslatedDescription self._records.Lookup(desc_iter.FileList.pop(0)) desc = "" - for line in string.split(unicode(self._records.LongDesc,"utf-8"),"\n"): + try: + s = unicode(self._records.LongDesc,"utf-8") + except UnicodeDecodeError,e: + s = _("Invalid unicode in description for '%s' (%s). " + "Please report.") % (name,e) + for line in string.split(s,"\n"): tmp = string.strip(line) if tmp == ".": desc += "\n" diff --git a/debian/changelog b/debian/changelog index cb818eea..9e0fe1be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,11 @@ python-apt (0.6.20ubuntu6) feisty; urgency=low * aptsources/distro.py: - fix crash in add_source (LP#85806) + * apt/package.py: + - handle invalid unicode more gracefully (LP#86215) + * rebuild against latest apt - -- + -- Michael Vogt Mon, 19 Feb 2007 16:34:52 +0100 python-apt (0.6.20ubuntu5) feisty; urgency=low diff --git a/debian/control b/debian/control index bf1ca1de..b243adb1 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: APT Development Team Uploaders: Matt Zimmerman , Michael Vogt Standards-Version: 3.7.2 XS-Python-Version: all -Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.46.4ubuntu7), apt-utils, python-all-dev, python-distutils-extra, cdbs, python-central (>= 0.5) +Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.46.4ubuntu8), apt-utils, python-all-dev, python-distutils-extra, cdbs, python-central (>= 0.5) Package: python-apt Architecture: any diff --git a/python/string.cc b/python/string.cc index 16adc8cd..d0926da5 100644 --- a/python/string.cc +++ b/python/string.cc @@ -53,9 +53,11 @@ PyObject *StrSizeToStr(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"O",&Obj) == 0) return 0; if (PyInt_Check(Obj)) - return CppPyString(SizeToStr(PyInt_AS_LONG(Obj))); + return CppPyString(SizeToStr(PyInt_AsLong(Obj))); + if (PyLong_Check(Obj)) + return CppPyString(SizeToStr(PyLong_AsLong(Obj))); if (PyFloat_Check(Obj)) - return CppPyString(SizeToStr(PyFloat_AS_DOUBLE(Obj))); + return CppPyString(SizeToStr(PyFloat_AsDouble(Obj))); PyErr_SetString(PyExc_TypeError,"Only understand integers and floats"); return 0; -- cgit v1.2.3 From 9a97aa02892342fa4fe7e2f8e3bfe314f194ef0e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Mar 2007 16:44:10 +0100 Subject: * python/depache.cc: - properly support isAutoInstalled flag --- debian/changelog | 4 +++- python/depcache.cc | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 974662bc..7e897122 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,10 @@ python-apt (0.6.20ubuntu13) feisty; urgency=low * fix in the duplicated source checking (thanks to Sebastian Heinlein) + * python/depache.cc: + - properly support isAutoInstalled flag - -- + -- Michael Vogt Wed, 14 Mar 2007 16:38:22 +0100 python-apt (0.6.20ubuntu12) feisty; urgency=low diff --git a/python/depcache.cc b/python/depcache.cc index 71e6a2e6..94ff708c 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -386,6 +386,20 @@ static PyObject *PkgDepCacheIsGarbage(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("b",state.Garbage)); } +static PyObject *PkgDepCacheIsAutoInstalled(PyObject *Self,PyObject *Args) +{ + pkgDepCache *depcache = GetCpp(Self); + + PyObject *PackageObj; + if (PyArg_ParseTuple(Args,"O!",&PackageType,&PackageObj) == 0) + return 0; + + pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); + pkgDepCache::StateCache &state = (*depcache)[Pkg]; + + return HandleErrors(Py_BuildValue("b",state.Flags & pkgCache::Flag::Auto)); +} + static PyObject *PkgDepCacheIsNowBroken(PyObject *Self,PyObject *Args) { pkgDepCache *depcache = GetCpp(Self); @@ -524,6 +538,7 @@ static PyMethodDef PkgDepCacheMethods[] = {"IsNowBroken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, {"IsInstBroken",PkgDepCacheIsInstBroken,METH_VARARGS,"Is pkg broken on the current install"}, {"IsGarbage",PkgDepCacheIsGarbage,METH_VARARGS,"Is pkg garbage (mark-n-sweep)"}, + {"IsAutoInstalled",PkgDepCacheIsAutoInstalled,METH_VARARGS,"Is pkg marked as auto installed"}, {"MarkedInstall",PkgDepCacheMarkedInstall,METH_VARARGS,"Is pkg marked for install"}, {"MarkedUpgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"}, {"MarkedDelete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"}, -- cgit v1.2.3