diff options
| -rw-r--r-- | python/cache.cc | 1 | ||||
| -rw-r--r-- | python/pkgrecords.cc | 5 | ||||
| -rw-r--r-- | tests/cache.py | 50 | ||||
| -rw-r--r-- | tests/pkgrecords.py | 34 |
4 files changed, 88 insertions, 2 deletions
diff --git a/python/cache.cc b/python/cache.cc index e8b947f4..850a97de 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -613,6 +613,7 @@ PyTypeObject PackageFileType = }; +// depends class static PyObject *DependencyRepr(PyObject *Self) { pkgCache::DepIterator &Dep = GetCpp<pkgCache::DepIterator>(Self); diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index d446388b..7f5aa0e2 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -50,8 +50,9 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) // Do the lookup Struct.Last = &Struct.Records.Lookup(pkgCache::VerFileIterator(*Cache,Cache->VerFileP+Index)); - Py_INCREF(Py_None); - return HandleErrors(Py_None); + + // always return true (to make it consistent with the pkgsrcrecords object + return Py_BuildValue("i", 1); } static PyMethodDef PkgRecordsMethods[] = diff --git a/tests/cache.py b/tests/cache.py new file mode 100644 index 00000000..e0cbb95c --- /dev/null +++ b/tests/cache.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python2.4 +# +# Test for the PkgSrcRecords code +# it segfaults for python-apt < 0.5.37 +# + +import apt_pkg +import sys + +def main(): + apt_pkg.init() + cache = apt_pkg.GetCache() + depcache = apt_pkg.GetDepCache(cache) + depcache.Init() + i=0 + all=cache.PackageCount + print "Running Cache test on all packages:" + # first, get all pkgs + for pkg in cache.Packages: + i += 1 + x = pkg.Name + # then get each version + for ver in pkg.VersionList: + # get some version information + a = ver.FileList + b = ver.VerStr + c = ver.Arch + d = ver.DependsListStr + dl = ver.DependsList + # get all dependencies (a dict of string->list, + # e.g. "depends:" -> [ver1,ver2,..] + for dep in dl.keys(): + # get the list of each dependency object + for depVerList in dl[dep]: + for z in depVerList: + # get all TargetVersions of + # the dependency object + for j in z.AllTargets(): + f = j.FileList + g = ver.VerStr + h = ver.Arch + k = ver.DependsListStr + j = ver.DependsList + pass + + print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)), + +if __name__ == "__main__": + main() + sys.exit(0) diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py new file mode 100644 index 00000000..8bfe4b82 --- /dev/null +++ b/tests/pkgrecords.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python2.4 +# +# Test for the PkgSrcRecords code +# it segfaults for python-apt < 0.5.37 +# + +import apt_pkg +import sys + +def main(): + apt_pkg.init() + cache = apt_pkg.GetCache() + depcache = apt_pkg.GetDepCache(cache) + depcache.Init() + i=0 + print "Running PkgRecords test on all packages:" + for pkg in cache.Packages: + i += 1 + records = apt_pkg.GetPkgRecords(cache) + if len(pkg.VersionList) == 0: + #print "no available version, cruft" + continue + version = depcache.GetCandidateVer(pkg) + file, index = version.FileList.pop(0) + if records.Lookup((file,index)): + #print records.FileName + x = records.FileName + y = records.LongDesc + pass + print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)), + +if __name__ == "__main__": + main() + sys.exit(0) |
