[Pkg-python-debian-commits] r67 trunk: * debian_bundle/deb822.py, debian_bundle/test_deb822.py:

John Wright john at movingsucks.org
Fri Jul 20 22:29:35 UTC 2007


------------------------------------------------------------
revno: 67
committer: John Wright <john at movingsucks.org>
branch nick: trunk
timestamp: Fri 2007-07-20 16:29:35 -0600
message:
  * debian_bundle/deb822.py, debian_bundle/test_deb822.py:
    - For multiline fields that start with a newline (e.g. Files in a .dsc,
      MD5Sum in Release files), the line with the "Field:" should not end in
      trailing whitespace.  Fixed and added test cases.
modified:
  debian/changelog
  debian_bundle/deb822.py
  debian_bundle/test_deb822.py
-------------- next part --------------
=== modified file 'debian/changelog'
--- a/debian/changelog	2007-07-15 09:43:21 +0000
+++ b/debian/changelog	2007-07-20 22:29:35 +0000
@@ -27,6 +27,9 @@
   * debian_bundle/deb822.py, debian_bundle/test_deb822.py, deb822.py:
     - Import latest version of deb822, and create a "dummy" top-level module
       for compatibility
+    - For multiline fields that start with a newline (e.g. Files in a .dsc,
+      MD5Sum in Release files), the line with the "Field:" should not end in
+      trailing whitespace.  Fixed and added test cases.
   * setup.py:
     - The version wasn't getting updated, so I've renamed it to setup.py.in,
       and added a __CHANGELOG_VERSION__ placeholder
@@ -42,7 +45,7 @@
     - Install old changelog for deb822 as
       /usr/share/doc/python-debian/HISTORY.deb822
 
- -- Stefano Zacchiroli <zack at debian.org>  Sun, 15 Jul 2007 11:37:05 +0200
+ -- John Wright <john.wright at hp.com>  Fri, 20 Jul 2007 16:27:24 -0600
 
 python-debian (0.1.3) unstable; urgency=low
 

=== modified file 'debian_bundle/deb822.py'
--- a/debian_bundle/deb822.py	2007-07-01 22:15:45 +0000
+++ b/debian_bundle/deb822.py	2007-07-20 22:29:35 +0000
@@ -265,7 +265,12 @@
         else:
             return_string = False
         for key, value in self.iteritems():
-            fd.write('%s: %s\n' % (key, value))
+            if value[0] == '\n':
+                # Avoid trailing whitespace after "Field:" if it's on its own
+                # line
+                fd.write('%s:%s' % (key, value))
+            else:
+                fd.write('%s: %s\n' % (key, value))
         if return_string:
             return fd.getvalue()
 

=== modified file 'debian_bundle/test_deb822.py'
--- a/debian_bundle/test_deb822.py	2007-07-01 22:15:45 +0000
+++ b/debian_bundle/test_deb822.py	2007-07-20 22:29:35 +0000
@@ -17,6 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+import re
 import deb822
 import unittest
 from StringIO import StringIO
@@ -350,6 +351,68 @@
         for k in deb822_.keys():
             self.assertEqual(deb822_[k], deb822_[k.lower()])
 
+    def test_multiline_trailing_whitespace_after_colon(self):
+        """Trailing whitespace after the field name on multiline fields
+
+        If the field's value starts with a newline (e.g. on MD5Sum fields in
+        Release files, or Files field in .dsc's, the dumped string should not
+        have a trailing space after the colon.  If the value does not start
+        with a newline (e.g. the control file Description field), then there
+        should be a space after the colon, as with non-multiline fields.
+        """
+        
+        dsc_string = """Format: 1.0
+Source: python-debian
+Binary: python-debian
+Architecture: all
+Version: 0.1.4
+Maintainer: Debian python-debian Maintainers <pkg-python-debian-maint at lists.alioth.debian.org>
+Uploaders: Adeodato Sim?? <dato at net.com.org.es>, Enrico Zini <enrico at debian.org>, James Westby <jw+debian at jameswestby.net>, Reinhard Tartler <siretart at tauware.de>, Stefano Zacchiroli <zack at debian.org>, John Wright <john at movingsucks.org>
+Standards-Version: 3.7.2
+Build-Depends: debhelper (>= 5.0.37.2), python, m4
+Build-Depends-Indep: python-support (>= 0.3)
+Files:
+ 065aa27943a4fc9e7020f324fed57b65 68575 python-debian_0.1.4.tar.gz
+Vcs-Bzr: http://bzr.debian.org/pkg-python-debian/trunk/
+"""
+        parsed_dsc = deb822.Deb822(dsc_string.splitlines())
+
+        # bad_re: match a line that starts with a "Field:", and ends in
+        # whitespace
+        bad_re = re.compile(r"^\S+:\s+$")
+        for line in parsed_dsc.dump().splitlines():
+            self.assert_(bad_re.match(line) is None,
+                         "There should not be trailing whitespace after the "
+                         "colon in a multiline field starting with a newline")
+
+        
+        control_paragraph = """Package: python-debian
+Architecture: all
+Depends: ${python:Depends}
+Suggests: python-apt
+Provides: python-deb822
+Conflicts: python-deb822
+Replaces: python-deb822
+Description: python modules to work with Debian-related data formats
+ This package provides python modules that abstract many formats of Debian
+ related files. Currently handled are:
+  * Debtags information (debian_bundle.debtags module)
+  * debian/changelog (debian_bundle.changelog module)
+  * Packages files, pdiffs (debian_bundle.debian_support module)
+  * Control files of single or multple RFC822-style paragraphs, e.g
+    debian/control, .changes, .dsc, Packages, Sources, Release, etc.
+    (debian_bundle.deb822 module)
+"""
+        parsed_control = deb822.Deb822(control_paragraph.splitlines())
+        field_re = re.compile(r"^\S+:")
+        field_with_space_re = re.compile(r"^\S+: ")
+        for line in parsed_control.dump().splitlines():
+            if field_re.match(line):
+                self.assert_(field_with_space_re.match(line),
+                             "Multiline fields that do not start with newline "
+                             "should have a space between the colon and the "
+                             "beginning of the value")
+        
 
 if __name__ == '__main__':
     unittest.main()



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