[PATCH] changelog: add iterator over changelog blocks

Filippo Giunchedi filippo at esaurito.net
Sun Aug 9 11:36:14 UTC 2009


Also add a basic test for the returned iterator

Closes: #539334
---
 debian/changelog           |    6 +++++-
 debian_bundle/changelog.py |    7 +++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 748ec97..6185069 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
 python-debian (0.1.15) UNRELEASED; urgency=low
 
+  [ John Wright ]
   * deb822: Don't ignore leading newlines on field data with apt_pkg
     (Closes: #466753)
   * changelog: Consistently parse different types of inputs.  The
@@ -9,7 +10,10 @@ python-debian (0.1.15) UNRELEASED; urgency=low
   * deb822: Faster non-shared storage by keeping a TagFile object
     around for each Deb822 object yielded
 
- -- John Wright <jsw at debian.org>  Thu, 30 Jul 2009 01:03:49 +0200
+  [ Filippo Giunchedi ]
+  * changelog: add iterator over changelog blocks (Closes: #539334)
+
+ -- Filippo Giunchedi <filippo at debian.org>  Sun, 09 Aug 2009 12:35:00 +0100
 
 python-debian (0.1.14) unstable; urgency=low
 
diff --git a/debian_bundle/changelog.py b/debian_bundle/changelog.py
index ae72a90..0beab84 100644
--- a/debian_bundle/changelog.py
+++ b/debian_bundle/changelog.py
@@ -495,6 +495,9 @@ class Changelog(object):
             cl += str(block)
         return cl
 
+    def __iter__(self):
+        return iter(self._blocks)
+
     def set_distributions(self, distributions):
         self._blocks[0].distributions = distributions
     distributions = property(lambda self: self._blocks[0].distributions,
@@ -658,6 +661,10 @@ class ChangelogTests(unittest.TestCase):
         for c in (c1, c2, c3):
             self.assertEqual(str(c), cl_data)
 
+    def test_block_iterator(self):
+        c = Changelog(open('test_changelog'))
+        self.assertEqual(len(c._blocks), len([b for b in c]))
+
 class VersionTests(unittest.TestCase):
 
     def _test_version(self, full_version, epoch, upstream, debian):
-- 
1.6.3.3


--4Ckj6UjgE2iN1+kY--





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