[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#321507: build-deps.py example doesn't work



Package: python-apt
Version: 0.6.13.1
Severity: minor

The build-deps.py example fails with the following error (and has
other problems later on):

1219:tbm@deprecation: ~doc/python-apt/examples] ./build-deps.py
Reading package lists... Done
Building dependency tree... Done
Traceback (most recent call last):
  File "./build-deps.py", line 24, in ?
    srcrecords = apt_pkg.GetPkgSrcRecords()
TypeError: function takes exactly 1 argument (0 given)


Attached is a patch that works for me.  I also replaced set() with a
list since Debian's current Python default 2.3 doesn't know about
set().  Using 'except KeyError' instead of cache.has_key() is a bit of
a kludge but it seems there's no has_key() and I couldn't figure out
what to use instead.


-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.10-1-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages python-apt depends on:
ii  python                        2.3.5-2    An interactive high-level object-o
ii  python2.3-apt                 0.6.13.1   Python interface to libapt-pkg

-- no debconf information

-- 
Martin Michlmayr
http://www.cyrius.com/
--- build-deps.py	2005-08-04 15:00:37.000000000 +0100
+++ /home/tbm/build-deps.py	2005-08-05 23:32:36.724229120 +0100
@@ -21,13 +21,18 @@
 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()
+	sys.exit(1)
+try:
+    base = cache[sys.argv[1]]
+except KeyError:
+	print "No package %s" % sys.argv[1]
+	sys.exit(1)
+all_build_depends = []
 
 depends = base.CurrentVer.DependsList
 for dep in depends["Depends"]:
@@ -40,7 +45,7 @@
 		bd = srcrecords.BuildDepends
 		#print "%s: %s " % (srcpkg_name, bd)
 		for b in bd:
-			all_build_depends.add(b[0])
+			all_build_depends.append(b[0])
 			
 
 print "\n".join(all_build_depends)

Reply to: