[Pkg-python-debian-commits] r56 /bzr/pkg-python-debian/trunk: Add allow_empty_author keyword to Changelog constructor.

James Westby jw+debian at jameswestby.net
Sun Jul 8 18:18:10 UTC 2007


------------------------------------------------------------
revno: 56
committer: James Westby <jw+debian at jameswestby.net>
branch nick: trunk
timestamp: Sun 2007-07-08 19:18:10 +0100
message:
  Add allow_empty_author keyword to Changelog constructor.
  
  This allows the author line to contain no information, in which
  case those attributes may be None.
modified:
  README.changelog
  debian/changelog
  debian_bundle/changelog.py
-------------- next part --------------
=== modified file 'README.changelog'
--- a/README.changelog	2007-06-17 14:34:12 +0000
+++ b/README.changelog	2007-07-08 18:18:10 +0000
@@ -91,6 +91,22 @@
      a Version object directly to assign to the version attribute of a
      Changelog object.
 
+If you have a changelog that may have no author information yet as it is still
+a work in progress, i.e. the author line is just
+
+    --
+
+rather than
+
+    -- Author <author at debian.org>  Thu, 12 Dec 2006 12:23:34 +0000
+
+then you can pass
+
+    allow_empty_author=True
+
+to the Changelog constructor. If you do this then the ``author`` and ``date``
+attributes may be ``None``.
+
 This file is (C) 2006-7 James Westby, and licensed under the GPL, see 
 changelog.py for details.
 

=== modified file 'debian/changelog'
--- a/debian/changelog	2007-07-01 04:00:27 +0000
+++ b/debian/changelog	2007-07-08 18:18:10 +0000
@@ -1,3 +1,12 @@
+python-debian (0.1.5) unstable; urgency=low
+
+  [ James Westby ]
+  * changelog.py
+    - Add allow_empty_author option to changelog to allow the author line
+      to have no information.
+
+ -- James Westby <jw+debian at jameswestby.net>  Sun, 08 Jul 2007 19:16:04 +0100
+
 python-debian (0.1.4) UNRELEASED; urgency=low
 
   [ Stefano Zacchiroli ]

=== modified file 'debian_bundle/changelog.py'
--- a/debian_bundle/changelog.py	2007-06-17 14:34:12 +0000
+++ b/debian_bundle/changelog.py	2007-07-08 18:18:10 +0000
@@ -186,24 +186,26 @@
 change = re.compile('^[ ][ ]+.*$')
 endline = re.compile('^ -- (.*)  (\w\w\w, +(\d| \d|\d\d) \w\w\w \d\d\d\d '+
       '\d\d:\d\d:\d\d [-+]\d\d\d\d( \(.*\))?)\s*$')
+endline_nodetails = re.compile('^ --(?: (.*)  (\w\w\w, +(\d| \d|\d\d) \w\w\w \d\d\d\d '+
+      '\d\d:\d\d:\d\d [-+]\d\d\d\d( \(.*\))?))?\s*$')
 
 class Changelog(object):
   """Represents a debian/changelog file. You can ask it several things about
   the file."""
 
 
-  def __init__(self, file=None, max_blocks=None):
+  def __init__(self, file=None, max_blocks=None, allow_empty_author=False):
     """Set up the Changelog for use. file is the contects of the changelog.
     """
     self._blocks = []
     if file is not None:
       try:
-        self.parse_changelog(file, max_blocks)
+        self.parse_changelog(file, max_blocks, allow_empty_author=allow_empty_author)
       except ChangelogParseError:
         pass
 
 
-  def parse_changelog(self, file, max_blocks=None):
+  def parse_changelog(self, file, max_blocks=None, allow_empty_author=False):
       before = 1
       inblock = 2
 
@@ -237,7 +239,10 @@
           if m is not None:
             changes.append(line)
           else:
-            m = endline.match(line)
+            if not allow_empty_author:
+              m = endline.match(line)
+            else:
+              m = endline_nodetails.match(line)
             if m is not None:
               state = before
               author = m.group(1)
@@ -437,6 +442,17 @@
                      (c2.full_version, c2.epoch, c2.upstream_version,
                       c2.debian_version))
 
+  def test_changelog_no_author(self):
+    c1 = Changelog("""gnutls13 (1:1.4.1-1) unstable; urgency=low
+
+  * New upstream release.
+
+ --
+""", allow_empty_author=True)
+    self.assertEqual(c1.author, None)
+    self.assertEqual(c1.date, None)
+    self.assertEqual(c1.package, "gnutls13")
+
   def test_magic_version_properties(self):
     c = Changelog(open('test_changelog').read())
 



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