diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-08-05 11:36:13 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-08-05 11:36:13 +0200 |
| commit | 5204dc7d2975121f529802ec403134502d6d4e45 (patch) | |
| tree | 964c562361f6f276740d47baf9e247771751e009 | |
| parent | 91e65ee1efd73fdbf507c2683bc6cc64fee9b37c (diff) | |
| parent | 1d96f36591c56798021c4e33d01a781507592add (diff) | |
| download | python-apt-5204dc7d2975121f529802ec403134502d6d4e45.tar.gz | |
* python/cache.cc:
- fix GetCandidateVer() reporting incorrect versions after
SetCandidateVer() was used. Thanks to Julian Andres Klode for
the test-case (LP: #237372)
* python/apt_instmodule.cc:
- do not change working dir in debExtractArchive() (LP: #184093)
* apt/cache.py:
- support "in" in apt.Cache() (LP: #251587)
| -rw-r--r-- | apt/cache.py | 3 | ||||
| -rw-r--r-- | debian/changelog | 13 | ||||
| -rw-r--r-- | po/python-apt.pot | 2 | ||||
| -rw-r--r-- | python/apt_instmodule.cc | 13 | ||||
| -rw-r--r-- | python/depcache.cc | 6 | ||||
| -rwxr-xr-x | tests/test_debextract.py | 13 | ||||
| -rw-r--r-- | tests/test_extract_archive.py | 10 |
7 files changed, 54 insertions, 6 deletions
diff --git a/apt/cache.py b/apt/cache.py index 384afe31..bbf2165b 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -101,6 +101,9 @@ class Cache(object): def has_key(self, key): return self._dict.has_key(key) + def __contains__(self, key): + return key in self._dict + def __len__(self): return len(self._dict) diff --git a/debian/changelog b/debian/changelog index 65f95664..3b70b925 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +python-apt (0.7.7.1ubuntu2) intrepid; urgency=low + + * python/cache.cc: + - fix GetCandidateVer() reporting incorrect versions after + SetCandidateVer() was used. Thanks to Julian Andres Klode for + the test-case (LP: #237372) + * python/apt_instmodule.cc: + - do not change working dir in debExtractArchive() (LP: #184093) + * apt/cache.py: + - support "in" in apt.Cache() (LP: #251587) + + -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 05 Aug 2008 11:35:32 +0200 + python-apt (0.7.7.1ubuntu1) intrepid; urgency=low * python/cache.cc: diff --git a/po/python-apt.pot b/po/python-apt.pot index 9dc6e202..7e731689 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: 2008-07-30 10:24+0200\n" +"POT-Creation-Date: 2008-07-31 12:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 43d5e7f7..ea703b21 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -74,6 +74,7 @@ static char *doc_debExtractArchive = static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { char *Rootdir = NULL; + char cwd[512]; PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) return 0; @@ -83,21 +84,27 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { if(Rootdir != NULL) { + getcwd(cwd, sizeof(cwd)); chdir(Rootdir); } // Open the file and associate the .deb FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); + if (_error->PendingError() == true) { + if (Rootdir != NULL) + chdir (cwd); + return HandleErrors(Py_BuildValue("b",false)); + } // extracts relative to the current dir pkgDirStream Extract; res = Deb.ExtractArchive(Extract); + if (Rootdir != NULL) + chdir (cwd); if (res == false) - return HandleErrors(); + return HandleErrors(Py_BuildValue("b",res)); } return HandleErrors(Py_BuildValue("b",res)); } diff --git a/python/depcache.cc b/python/depcache.cc index 5664a6d8..2446dc71 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -197,7 +197,7 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); - pkgCache::VerIterator I = GetCpp<pkgCache::VerIterator>(VersionObj); + pkgCache::VerIterator &I = GetCpp<pkgCache::VerIterator>(VersionObj); if(I.end()) { return HandleErrors(Py_BuildValue("b",false)); } @@ -215,7 +215,9 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj); - pkgCache::VerIterator I = depcache->GetCandidateVer(Pkg); + pkgDepCache::StateCache & State = (*depcache)[Pkg]; + pkgCache::VerIterator I = State.CandidateVerIter(*depcache); + if(I.end()) { Py_INCREF(Py_None); return Py_None; diff --git a/tests/test_debextract.py b/tests/test_debextract.py new file mode 100755 index 00000000..53241e92 --- /dev/null +++ b/tests/test_debextract.py @@ -0,0 +1,13 @@ +#!/usr/bin/python + +import apt_inst +import sys + +def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): + print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % ( + What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor) + +member = "data.tar.lzma" +if len(sys.argv) > 2: + member = sys.argv[2] +apt_inst.debExtract(open(sys.argv[1]), Callback, member) diff --git a/tests/test_extract_archive.py b/tests/test_extract_archive.py new file mode 100644 index 00000000..ce202b06 --- /dev/null +++ b/tests/test_extract_archive.py @@ -0,0 +1,10 @@ +#!/usr/bin/python + +import apt +import apt_inst +import os +import sys + +print os.getcwd() +apt_inst.debExtractArchive(open(sys.argv[1]), "/tmp/") +print os.getcwd() |
