[PATCH] copyright: add all_paragraphs iterator
John Wright
jsw at debian.org
Fri Sep 12 06:43:57 UTC 2014
Once again, I suck at email. Need to rebind "r" to group-reply...
On Thu, Sep 11, 2014 at 11:36:56PM -0700, John Wright wrote:
> LGTM.
>
> On Thu, Sep 11, 2014 at 02:29:05PM +0200, Stefano Zacchiroli wrote:
> > On Thu, Sep 11, 2014 at 02:21:34PM +0200, Stefano Zacchiroli wrote:
> > > + return itertools.chain([self.header], (p for p in self.__paragraphs))
> >
> > As additional rationale for this change: there seems to be no way, with
> > the current copyright API, to iterate over the various paragraphs in the
> > debian/copyright file, that preserves the parsing order. That is IMHO
> > desirable, e.g. for rendering purposes more complex than what currently
> > dump() offers.
> >
> > As an alternative to this implementation, one might want to expose
> > __paragraphs as a read-only property, but that would have the
> > inconvenient of excluding the header paragraph.
> >
> > All in all I prefer the approach implemented by this patch (surprise
> > surprise :-)).
>
> I like this better too. I was reluctant to expose the paragraphs
> directly, but having an iterator over all of them is convenient.
>
> > In addition to this change, we might also consider making Copyright
> > objects themselves iterable, by simply calling all_paragraphs() behind
> > the scenes. (FWIW even in that case I would still keep all_paragraphs()
> > around, for uniformity with the other all_* methods.)
>
> Sure, I suppose "for paragraph in copyright: ..." reads kinda nicely.
> I'm always afraid that as soon as I override something like __iter__
> I'll wish it had returned something different, but there probably isn't
> another reasonable thing to iterate over in this case.
>
> > [ And, of course, Murphy law: I've though about this only immediately
> > after the upload. Oh well... ]
>
> Uploads are easy. :-)
>
> > > -License: ABC
> > > - [ABC TEXT]
> > > -
> > > Files: debian/*
> > > Copyright: Copyright 2003 Debian Developer <someone at debian.org>
> > > License: 123
> > > @@ -111,6 +108,9 @@ Copyright: Copyright 2003 Debian Developer <someone at debian.org>
> > > Copyright 2004 Someone Else <foo at bar.com>
> > > License: 123
> > >
> > > +License: ABC
> > > + [ABC TEXT]
> > > +
> > > License: 123
> > > [123 TEXT]
> >
> > I've changed the paragraph order in one of the copyright test cases to
> > have a simple way to test all_paragraphs(), which was ruled out by the
> > interleaving of Files and License paragraphs. AFAICT this has no adverse
> > effect on other tests.
>
> It was interleaved to ensure that all_files_paragraphs properly skipped
> the license paragraphs, but I think this is fine.
>
> Thanks for adding this.
>
> --
> John Wright <jsw at debian.org>
--
John Wright <jsw at debian.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-python-debian-maint/attachments/20140911/60a12937/attachment.sig>
More information about the pkg-python-debian-maint
mailing list