]> git.decadent.org.uk Git - dak.git/commitdiff
Alter generate_reject_messages to return a generator.
authorChris Lamb <lamby@debian.org>
Sat, 31 Oct 2009 10:29:14 +0000 (10:29 +0000)
committerChris Lamb <lamby@debian.org>
Sat, 31 Oct 2009 23:00:12 +0000 (23:00 +0000)
Signed-off-by: Chris Lamb <lamby@debian.org>
daklib/lintian.py
tests/test_lintian.py

index 260474ec50ce53d5b07bb8bddd60576bac60b382..8e65d3f5db09db29fb928ad5244d0d17900c588d 100644 (file)
@@ -16,11 +16,9 @@ def parse_lintian_output(output):
 def generate_reject_messages(parsed_tags, tag_definitions, log=lambda *args: args):
     """
     Generates package reject messages by comparing parsed lintian output with
-    tag definitions.
+    tag definitions. Returns a generator containing the reject messages.
     """
 
-    rejects = []
-
     tags = set()
     for values in tag_definitions.values():
         for tag in values:
@@ -41,25 +39,18 @@ def generate_reject_messages(parsed_tags, tag_definitions, log=lambda *args: arg
                 # Overriding this tag is NOT allowed.
 
                 log('ftpmaster does not allow tag to be overridable', etag)
-                rejects.append(
-                    "%s: Overriden tag %s found, but this tag "
+                yield "%s: Overriden tag %s found, but this tag " \
                     "may not be overridden." % (epackage, etag)
-                )
 
         else:
             # Tag is known and not overridden; reject
-            rejects.append(
-                "%s: Found lintian output: '%s %s', automatically "
+            yield "%s: Found lintian output: '%s %s', automatically " \
                 "rejected package." % (epackage, etag, etext)
-            )
 
             # Now tell if they *might* override it.
             if etag in tag_definitions['nonfatal']:
                 log("auto rejecting", "overridable", etag)
-                rejects.append(
-                    "%s: If you have a good reason, you may override this "
-                    "lintian tag." % epackage)
+                yield "%s: If you have a good reason, you may override this " \
+                   "lintian tag." % epackage
             else:
                 log("auto rejecting", "not overridable", etag)
-
-    return rejects
index 27d13680bf8855bae44b0e9a11e09ddafb334b71..4a574a9d1a5c5fdba63d5ff3136b5a3481e19f61 100755 (executable)
@@ -43,7 +43,8 @@ class ParseLintianTestCase(DakTestCase):
 
 class GenerateRejectMessages(DakTestCase):
     def assertNumReject(self, input, defs, num):
-        self.assertEqual(len(generate_reject_messages(input, defs)), num)
+        msgs = list(generate_reject_messages(input, defs))
+        self.assertEqual(len(msgs), num)
 
     def testUnknownTag(self):
         self.assertNumReject(