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

Re: Bug#380173: ITP: deb822 -- Read and manipulate RFC822-like files (e.g. .dsc and .changes)

On Fri, Jul 28, 2006 at 08:36:08AM +0200, Thomas Viehmann wrote:
> The copyright file is broken. cf. #336982
> >  deb822 abstractifies the RFC822 format used in Debian's control files.  You
> >  can use a deb822 object like a Python dictionary, referring to control fields
> >  as dictionary keys.
> Is it really worth doing this?
> Python readily has rfc822 parsing and the added value seems marginal to
> the point where I'd not be looking for a module when I had a task to do
> that could use it.

Using rfc822 was problematic, especially if you care about preserving
the order of the fields after modification.  Since it was meant for
email headers, where multiline fields are essentially the same as
single-line fields, rfc822's handling of e.g. Description, Files, and
Changes fields was less than ideal.

What makes deb822 useful is the fact that it "knows" about some things
that are specific to Debian's control format, rather than only generic
rfc822.  For instance, if you instantiate the deb822.changes or
deb822.dsc class with an appropriate file, you can use the object's
files() method to get a list of dictionaries containing file

  >>> import deb822
  >>> c = deb822.changes(open('../deb822_0.1_source.changes'))
  >>> c.files()
  [{'md5sum': '66beaeec167d541a02736a083d90e054',
    'name': 'deb822_0.1.dsc',
    'priority': 'optional',
    'section': 'python',
    'size': '310'},
   {'md5sum': '41c76b849f8c4feeda44e82c77f51977',
    'name': 'deb822_0.1.tar.gz',
    'priority': 'optional',
    'section': 'python',
    'size': '16077'}]

Yes, you could parse this on your own fairly easily, but now it's
already done for you.  Also, if you modify one of the fields, the dump()
method is guaranteed to output it in its original position (unlike
rfc822).  There are methods for "merging" two changes files as well.
(SystemImager's build process requires building binaries on multiple
archs for a single upload, after which the changes files need to be
merged.  See [1].)

It may be possible to subclass or make a wrapper around rfc822.Message,
but since this was written to get around some shortcomings of the rfc822
module for Debian control files, this isn't yet a priority for me.

> Additionally, shipping python modules without documentation seems a bad
> idea if you want it to be useful.

I agree.  At the least, a few examples will be included by the time I
actually get this uploaded.  Full documentation will be the next

 [1]: http://svn.systemimager.org/filedetails.php?repname=systemimager-debian&path=%2Ftrunk%2Fdebian%2FREADME.NMU&rev=0&sc=0

John Wright

Reply to: