From f17fc818cca41668bb6358e490ff3278e64fa493 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 5 Oct 2011 10:32:04 +0200 Subject: * tests/test_apt_cache.py: - add __cmp__ to apt.Package so that sort() sorts by name on list of package objects --- apt/package.py | 3 +++ debian/changelog | 3 +++ tests/test_apt_cache.py | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/apt/package.py b/apt/package.py index 4104f93e..cb373c2e 100644 --- a/apt/package.py +++ b/apt/package.py @@ -707,6 +707,9 @@ class Package(object): return '' % (self._pkg.name, self._pkg.architecture, self._pkg.id) + def __cmp__(self, other): + return cmp(self.name, other.name) + def candidate(self): """Return the candidate version of the package. diff --git a/debian/changelog b/debian/changelog index 0864d725..b7876e51 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,9 @@ python-apt (0.8.1) UNRELEASED; urgency=low that needs universe enabled as well (plus add test) * apt/progress/gtk2.py: - update to the latest vte API for child-exited (LP: #865388) + * tests/test_apt_cache.py: + - add __cmp__ to apt.Package so that sort() sorts by name + on list of package objects -- Julian Andres Klode Tue, 07 Jun 2011 14:00:22 +0200 diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 2f812059..9c1f549f 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -181,5 +181,16 @@ class TestAptCache(unittest.TestCase): apt_pkg.config.set("dir::etc::sourcelist", old_source_list) apt_pkg.config.set("dir::etc::sourceparts", old_source_parts) + def test_package_cmp(self): + cache = apt.Cache() + l = [] + l.append(cache["libc6"]) + l.append(cache["xterm"]) + l.append(cache["apt"]) + l.sort() + self.assertEqual([p.name for p in l], + ["apt", "libc6", "xterm"]) + + if __name__ == "__main__": unittest.main() -- cgit v1.2.3 From 50756e0efb5081d3379fa874ca41ab57bdf2798d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 09:10:46 +0200 Subject: * tests/test_aptsources.py: - use unlzma from xz-utils instead of lzma to follow what dpkg is using (LP: #868188) * debian/control: - add recommends to xz-lzma to ensure we have the unlzma command --- debian/changelog | 5 +++++ debian/control | 2 +- python/tar.cc | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index b7876e51..33b0d6e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,11 @@ python-apt (0.8.1) UNRELEASED; urgency=low * tests/test_apt_cache.py: - add __cmp__ to apt.Package so that sort() sorts by name on list of package objects + * tests/test_aptsources.py: + - use unlzma from xz-utils instead of lzma to follow what dpkg + is using (LP: #868188) + * debian/control: + - add recommends to xz-lzma to ensure we have the unlzma command -- Julian Andres Klode Tue, 07 Jun 2011 14:00:22 +0200 diff --git a/debian/control b/debian/control index 01e8884e..541e4c36 100644 --- a/debian/control +++ b/debian/control @@ -22,7 +22,7 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-apt-common -Recommends: lsb-release, iso-codes, python2.6 +Recommends: lsb-release, iso-codes, python2.6, xz-lzma Breaks: packagekit-backend-apt (<= 0.4.8-0ubuntu4), computer-janitor (<< 1.14.1-1+), debdelta (<< 0.41+), diff --git a/python/tar.cc b/python/tar.cc index b994d4e7..4109776c 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -181,7 +181,7 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) if (strcmp(".bz2", &Chunk[strlen(Chunk)-4]) == 0) Comp = "bzip2"; else if(strcmp(".lzma", &Chunk[strlen(Chunk)-5]) == 0) - Comp = "lzma"; + Comp = "unlzma"; ExtractTar Tar(Deb.GetFile(),Member->Size,Comp); ProcessTar Proc(Function); if (Tar.Go(Proc) == false) -- cgit v1.2.3 From b7ce3c2b47e1234631e00cb0ba8a86fa0aa9c8d8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 10:08:44 +0200 Subject: * python/apt_pkgmodule.cc: - add apt_pkg.get_architectures() call --- debian/changelog | 2 ++ po/python-apt.pot | 20 ++++++++++---------- python/apt_pkgmodule.cc | 27 +++++++++++++++++++++++++++ tests/test_apt_cache.py | 5 +++++ 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index 39c506e6..6fbc5241 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ python-apt (0.8.2) UNRELEASED; urgency=low - updated, thanks to Joe Dalton (closes: #631309) * po/sr.po: - updated, thanks to Nikola Nenadic (closes: #638308) + * python/apt_pkgmodule.cc: + - add apt_pkg.get_architectures() call [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) diff --git a/po/python-apt.pot b/po/python-apt.pot index 70c68099..48b4fb18 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-19 18:07+0200\n" +"POT-Creation-Date: 2011-10-21 10:05+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -455,11 +455,11 @@ msgstr "" msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:1065 ../apt/package.py:1171 +#: ../apt/package.py:1068 ../apt/package.py:1174 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:1177 +#: ../apt/package.py:1180 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -468,7 +468,7 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:1184 +#: ../apt/package.py:1187 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." @@ -535,26 +535,26 @@ msgstr "" msgid "Cannot install '%s'" msgstr "" -#: ../apt/debfile.py:508 +#: ../apt/debfile.py:510 msgid "Python-debian module not available" msgstr "" -#: ../apt/debfile.py:542 +#: ../apt/debfile.py:544 msgid "" "Automatically decompressed:\n" "\n" msgstr "" -#: ../apt/debfile.py:548 +#: ../apt/debfile.py:550 msgid "Automatically converted to printable ascii:\n" msgstr "" -#: ../apt/debfile.py:638 +#: ../apt/debfile.py:640 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" -#: ../apt/debfile.py:648 +#: ../apt/debfile.py:650 msgid "An essential package would be removed" msgstr "" @@ -605,6 +605,6 @@ msgstr "" msgid "Please insert a Disc in the drive and press enter" msgstr "" -#: ../apt/cache.py:149 +#: ../apt/cache.py:148 msgid "Building data structures" msgstr "" diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e8490b4e..03c88e9a 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -393,6 +394,29 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) return 0; } /*}}}*/ +// get_architectures - return the list of architectures /*{{{*/ +// --------------------------------------------------------------------- +static const char *doc_GetArchitectures = + "get_architectures() -> list\n\n" + "Return the list of supported architectures on this system. On a \n" + "multiarch system this can be more than one.";; +static PyObject *GetArchitectures(PyObject *Self,PyObject *Args) +{ + PyObject *Obj; + if (PyArg_ParseTuple(Args,"",&Obj) == 0) + return 0; + + PyObject *List = PyList_New(0); + vector arches = APT::Configuration::getArchitectures(); + vector::const_iterator I; + for (I = arches.begin(); I != arches.end(); I++) + { + PyList_Append(List, CppPyString(*I)); + } + + return List; +} + /*}}}*/ // init - 3 init functions /*{{{*/ // --------------------------------------------------------------------- static char *doc_Init = @@ -539,6 +563,9 @@ static PyMethodDef methods[] = {"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, + // multiarch + {"get_architectures", GetArchitectures, METH_VARARGS, doc_GetArchitectures}, + // Strings {"check_domain_list",StrCheckDomainList,METH_VARARGS, "check_domain_list(host: str, domains: str) -> bool\n\n" diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 2b742dfa..0d80f617 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -191,6 +191,11 @@ class TestAptCache(unittest.TestCase): self.assertEqual([p.name for p in l], ["apt", "libc6", "xterm"]) + def test_get_architectures(self): + main_arch = apt.apt_pkg.config.get("APT::Architecture") + arches = apt_pkg.get_architectures() + self.assertTrue(main_arch in arches) + if __name__ == "__main__": unittest.main() -- cgit v1.2.3 From d7c8f470a236d70fa6ce8eb0e522702fee64ff5e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 21 Oct 2011 10:11:02 +0200 Subject: python/apt_pkgmodule.cc: improve docstring --- po/python-apt.pot | 2 +- python/apt_pkgmodule.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/po/python-apt.pot b/po/python-apt.pot index 48b4fb18..d19871d0 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-21 10:05+0200\n" +"POT-Creation-Date: 2011-10-21 10:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 03c88e9a..8532b1e3 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -399,7 +399,8 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) static const char *doc_GetArchitectures = "get_architectures() -> list\n\n" "Return the list of supported architectures on this system. On a \n" - "multiarch system this can be more than one.";; + "multiarch system this can be more than one. The main architectures\n" + "is the first item in the list.";; static PyObject *GetArchitectures(PyObject *Self,PyObject *Args) { PyObject *Obj; -- cgit v1.2.3 From 1948d5d03887eb81ea7797c0f23049ef6c3895ce Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Nov 2011 10:05:55 +0100 Subject: * apt/cache.py: - remove "print" when creating dirs in apt.Cache(rootdir=dir), thanks to Martin Pitt --- apt/cache.py | 2 +- debian/changelog | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apt/cache.py b/apt/cache.py index bab5c277..a4585277 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -111,7 +111,7 @@ class Cache(object): ] for d in dirs: if not os.path.exists(rootdir + d): - print "creating: ", rootdir + d + #print "creating: ", rootdir + d os.makedirs(rootdir + d) for f in files: if not os.path.exists(rootdir + f): diff --git a/debian/changelog b/debian/changelog index 6fbc5241..f5ae2b79 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,9 @@ python-apt (0.8.2) UNRELEASED; urgency=low - updated, thanks to Nikola Nenadic (closes: #638308) * python/apt_pkgmodule.cc: - add apt_pkg.get_architectures() call + * apt/cache.py: + - remove "print" when creating dirs in apt.Cache(rootdir=dir), + thanks to Martin Pitt [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) -- cgit v1.2.3