[PATCH] copyright: add all_paragraphs iterator

Stefano Zacchiroli zack at debian.org
Thu Sep 11 12:29:05 UTC 2014


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 :-)).

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.)

[ And, of course, Murphy law: I've though about this only immediately
  after the upload. Oh well... ]

> -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.

Cheers.
-- 
Stefano Zacchiroli  . . . . . . .  zack at upsilon.cc . . . . o . . . o . o
Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o
Former Debian Project Leader  . . @zack on identi.ca . . o o o . . . o .
« the first rule of tautology club is the first rule of tautology club »
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-python-debian-maint/attachments/20140911/be8aeec7/attachment.sig>


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