Parsing single debian/control file
Andreas Tille
tille at debian.org
Fri May 4 13:25:57 UTC 2012
Hi John,
On Fri, May 04, 2012 at 05:08:41AM -0700, John Wright wrote:
> Hi Andreas,
>
> Sorry I didn't get back to you earlier.
Well, I had other things to do meanwhile - so no real harm caused by the
delay. :-)
> On Wed, Apr 18, 2012 at 09:25:46PM +0200, Andreas Tille wrote:
> > Hi John,
> >
> > I wonder what might be the proper mailing list to ask questions
> > like this - feel free to quote me fully or in parts in public.
>
> I have added the package discussion mailing list to Cc.
Thanks. perhaps it would have helped if I would have read the
accompanied README file - sorry for my ignorance.
> > ctrl = open('debian/control','r')
> > for ctrlstanza in deb822.Packages.iter_paragraphs(ctrl):
> > print ctrlstanza
> >
>
> The code you have above is correct (though I would generally use
> deb822.Deb822.iter_paragraphs - Packages and Sources may have some
> special semantics).
OK, thanks for the hint.
> The string representation of a Deb822 instance is
> designed to be just like its input - idential to it, if possible. But
> it works like a dict, so you can do
>
> for stanza in deb822.Deb822.iter_paragraphs(ctrl):
> if 'source' in stanza:
> print 'Source:', stanza['source']
> if 'package' in stanza:
> print 'Package:', stanza['package']
>
> The keys are case-insensitive. You can also add new keys. The string
> representation will place the new fields at the end, using whatever
> capitalization you initially used.
Thanks to a (private) tip of Zack I now managed to get this working. My
initial problem somehow magically went away - I do not remember exactly
why I had the feeling that keys like for instance 'Source' or 'Package'
were missing - now everything works just fine.
> > Something related but not high priority for me and thus perhaps an issue
> > for a wishlist bug (have not checked BTS for it): Since DEP5 is accepted
> > the parsing of debian/copyright might be an interesting feature as well.
>
> I haven't seen a request for this yet. Please do file a bug!
Done. As I said no really high priority - but now it is recorded
somewhere ...
Kind regards
Andreas.
--
http://fam-tille.de
More information about the pkg-python-debian-discuss
mailing list