Bug#431087: please yield dictionaries instead of tuple lists when parsing Packages

Stefano Zacchiroli zack at debian.org
Fri Jun 29 15:38:17 UTC 2007


Package: python-debian
Version: 0.1.3
Severity: wishlist
File: /usr/share/python-support/python-debian/debian_bundle/debian_support.py
Tags: patch

Parsing Packages file currently yields lists of tuples <field name,
field value>. I found that unfortunate given that I'm convinced that 99%
of the times one parses a Package file is to look at *some* fields of a
given package entry rather than at *all* fields. Having a dictionary
would help in this respect and rebuilding the list of tuples is just a
matter of list(dict.iteritems()).

My argument is hence to optimize the most frequent usage pattern.

Also, given that caseness is not significant as per RFC 822, I recommend
to lowercase field names before creating the dictionary.

The attached patch implements both this requests, can you please
consider applying it?

Many thanks in advance (and as a whole for the python-debian effort!)
Cheers.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-1-686 (SMP w/1 CPU core)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-debian depends on:
ii  python                        2.4.4-6    An interactive high-level object-o
ii  python-support                0.6.4      automated rebuilding support for p

python-debian recommends no packages.

-- no debconf information
-------------- next part --------------
--- /usr/share/python-support/python-debian/debian_bundle/debian_support.py	2007-06-17 16:50:52.000000000 +0200
+++ debian_support.py.zack	2007-06-29 17:32:44.000000000 +0200
@@ -206,9 +206,9 @@
                     contents = "%s\n%s" % (contents, ncontents)
                 else:
                     break
-            pkg.append((name, contents))
+            pkg.append((name.lower(), contents))
         if pkg:
-            yield pkg
+            yield dict(pkg)
 
     def raiseSyntaxError(self, msg, lineno=None):
         if lineno is None:


More information about the pkg-python-debian-maint mailing list