diff options
| author | Julian Andres Klode <jak@debian.org> | 2011-04-04 09:56:18 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2011-04-04 09:56:18 +0200 |
| commit | 71e419a088092a3f6c62836d7bd09f952133fb3f (patch) | |
| tree | 69f33b78b78b94e6c84f56f903e000c2fd579232 | |
| parent | e12fa9b90458f31b9bc3ceeab7c4c106113cab53 (diff) | |
| download | python-apt-71e419a088092a3f6c62836d7bd09f952133fb3f.tar.gz | |
* python/cache.cc:
- Add Package.get_fullname() and Package.architecture
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | doc/source/library/apt_pkg.rst | 21 | ||||
| -rw-r--r-- | python/cache.cc | 31 |
3 files changed, 54 insertions, 4 deletions
diff --git a/debian/changelog b/debian/changelog index 0aed50d9..18e4354b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,11 @@ python-apt (0.7.100.3) UNRELEASED; urgency=low - add test for xz compression * update priority of python3-apt to match the archive - -- Michael Vogt <mvo@debian.org> Mon, 21 Mar 2011 15:46:50 +0100 + [ Julian Andres Klode ] + * python/cache.cc: + - Add Package.get_fullname() and Package.architecture + + -- Julian Andres Klode <jak@debian.org> Mon, 04 Apr 2011 09:48:10 +0200 python-apt (0.7.100.2) unstable; urgency=low diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst index 81358bac..426cb97e 100644 --- a/doc/source/library/apt_pkg.rst +++ b/doc/source/library/apt_pkg.rst @@ -437,18 +437,35 @@ Resolving Dependencies with :class:`ProblemResolver` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. class:: Package - Represent a package. A package is uniquely identified by its name - and each package can have zero or more versions which can be + Represent a package. A package is uniquely identified by its name and + architecture and each package can have zero or more versions which can be accessed via the :attr:`version_list` property. Packages can be installed and removed by a :class:`DepCache` object. Attributes: + .. attribute: architecture + + The architecture of the package. This is relevant on multi-arch + systems only. Please note that if a package is Architecture: all, + this value is not "all", but the architecture of the package file + it comes from. + + .. versionadded:: 0.7.100.3 + .. attribute:: current_ver The version currently installed as a :class:`Version` object, or None if the package is not installed. + .. method:: get_fullname([pretty: bool = False]) -> str + + Get the full name of the package, including the architecture. If + *pretty* is ``True``, the architecture is omitted for native packages, + that is, an amd64 "apt" package on an amd64 system would give "apt". + + .. versionadded:: 0.7.100.3 + .. attribute:: has_provides A boolean value determining whether the list available via the diff --git a/python/cache.cc b/python/cache.cc index cd51fcc3..190d4f27 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -509,6 +509,7 @@ PyTypeObject PyPackageList_Type = } MkGet(PackageGetName,PyString_FromString(Pkg.Name())) +MkGet(PackageGetArch,PyString_FromString(Pkg.Arch())) MkGet(PackageGetSection,Safe_FromString(Pkg.Section())) MkGet(PackageGetRevDependsList,CppPyObject_NEW<RDepListStruct>(Owner, &PyDependencyList_Type, Pkg.RevDependsList())) @@ -524,6 +525,25 @@ MkGet(PackageGetImportant,PyBool_FromLong((Pkg->Flags & pkgCache::Flag::Importan #undef MkGet #undef Owner +static const char PackageGetFullName_doc[] = + "get_fullname([pretty: bool = False]) -> str\n\n" + "Get the full name of the package, including the architecture. If\n" + "'pretty' is True, the architecture is omitted for native packages,\n" + "that is, and amd64 apt package on an amd64 system would give 'apt'."; +static PyObject *PackageGetFullName(PyObject *Self,PyObject *Args,PyObject *kwds) +{ + pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self); + char pretty = 0; + char *kwlist[] = {"pretty", 0}; + + if (PyArg_ParseTupleAndKeywords(Args, kwds, "|b", kwlist, + &pretty) == 0) + return 0; + + + return CppPyString(Pkg.FullName(pretty)); +} + static PyObject *PackageGetVersionList(PyObject *Self,void*) { pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self); @@ -565,9 +585,18 @@ static PyObject *PackageGetCurrentVer(PyObject *Self,void*) Pkg.CurrentVer()); } + +static PyMethodDef PackageMethods[] = +{ + {"get_fullname",(PyCFunction)PackageGetFullName,METH_VARARGS|METH_KEYWORDS, + PackageGetFullName_doc}, + {} +}; + static PyGetSetDef PackageGetSet[] = { {"name",PackageGetName,0, "The name of the package."}, + {"architecture",PackageGetArch,0, "The architecture of the package."}, {"section",PackageGetSection,0, "The section of the package."}, {"rev_depends_list",PackageGetRevDependsList,0, @@ -656,7 +685,7 @@ PyTypeObject PyPackage_Type = 0, // tp_weaklistoffset 0, // tp_iter 0, // tp_iternext - 0, // tp_methods + PackageMethods, // tp_methods 0, // tp_members PackageGetSet, // tp_getset }; |
