On Sat, Aug 06, 2005 at 12:10:28AM +0100, Martin Michlmayr wrote:
> * Martin Michlmayr <[EMAIL PROTECTED]> [2005-08-05 23:35]:
> > list since Debian's current Python default 2.3 doesn't know about
> > set().
> 
> Right, but I thereby changed in the behaviour in a bad way.

Thanks for your bugreport and thanks for your patch. I commited a
slighly changed version to my baz archive
([EMAIL PROTECTED]/python-apt--mvo--0). Attached is a
patch. It still uses a Set to avoid duplicating build depends but this
time using "import sets" (works on python2.3). 
 
> BTW, I found one more problem.  This happens when you use a package
> that exists in the archive but is not installed on your machine:
>
> 2494:[EMAIL PROTECTED]: ~] ./build-deps.py dadadodo
[..]
> AttributeError: 'NoneType' object has no attribute 'DependsList'
> zsh: exit 1     ./build-deps.py dadadodo

This one is fixed now too. It uses the depcache.GetCandidateVer()
interface now.

Cheers,
 Michael

-- 
Linux is not The Answer. Yes is the answer. Linux is The Question. - Neo
* looking for [EMAIL PROTECTED]/python-apt--mvo--0--patch-68 to compare with
* comparing to [EMAIL PROTECTED]/python-apt--mvo--0--patch-68: ... done.

* modified files

--- orig/debian/changelog
+++ mod/debian/changelog
@@ -1,3 +1,10 @@
+python-apt (0.6.14) unstable; urgency=low
+
+  * doc/examples/build-deps.py:
+    - fixed/improved (thanks to Martin Michlmayr, closes: #321507)
+
+ --
+
 python-apt (0.6.13) unstable; urgency=low
 
   * support for depcache added


--- orig/doc/examples/build-deps.py
+++ mod/doc/examples/build-deps.py
@@ -2,11 +2,12 @@
 
 import apt_pkg
 import sys
-
+import sets    # only needed for python2.3, python2.4 supports this naively 
 
 def get_source_pkg(pkg, records, depcache):
-       # FIXME: use candidate version here
        version = depcache.GetCandidateVer(pkg)
+       if not version:
+               return None
        file, index = version.FileList.pop(0)
        records.Lookup((file, index))
        if records.SourcePkg != "":
@@ -21,18 +22,26 @@
 depcache = apt_pkg.GetDepCache(cache)
 depcache.Init()
 records = apt_pkg.GetPkgRecords(cache)
-srcrecords = apt_pkg.GetPkgSrcRecords()
+srcrecords = apt_pkg.GetPkgSrcRecords(cache)
 
 # base package that we use for build-depends calculation
 if len(sys.argv) < 2:
-       print "need a pkgname as argument"
-base = cache[sys.argv[1]]
-all_build_depends = set()
+       print "need a package name as argument"
+       sys.exit(1)
+try:
+       base = cache[sys.argv[1]]
+except KeyError:
+       print "No package %s found" % sys.argv[1]
+       sys.exit(1)
+all_build_depends = sets.Set()
 
-depends = base.CurrentVer.DependsList
+depends = depcache.GetCandidateVer(base).DependsList
 for dep in depends["Depends"]:
        pkg = dep[0].TargetPkg
        srcpkg_name = get_source_pkg(pkg, records, depcache)
+       if not srcpkg_name:
+               print "Can't find source package for '%s'" % pkg.Name
+               continue
        srcrec = srcrecords.Lookup(srcpkg_name)
        if srcrec:
                #print srcrecords.Package



* added files

--- /dev/null
+++ mod/{arch}/python-apt/python-apt--mvo/python-apt--mvo--0/[EMAIL 
PROTECTED]/patch-log/patch-69
@@ -0,0 +1,12 @@
+Revision: python-apt--mvo--0--patch-69
+Archive: [EMAIL PROTECTED]
+Creator: Michael Vogt <[EMAIL PROTECTED]>
+Date: Mon Aug  8 15:10:03 CEST 2005
+Standard-date: 2005-08-08 13:10:03 GMT
+Modified-files: debian/changelog doc/examples/build-deps.py
+New-patches: [EMAIL PROTECTED]/python-apt--mvo--0--patch-69
+Summary: * made the build-deps.py example usefull
+Keywords: 
+
+
+

Reply via email to