deb.changelog: allow to extract author and date
authorGuido Günther <agx@sigxcpu.org>
Thu, 15 Mar 2012 20:19:48 +0000 (21:19 +0100)
committerGuido Günther <agx@sigxcpu.org>
Thu, 15 Mar 2012 20:19:48 +0000 (21:19 +0100)
gbp/deb/changelog.py
tests/test_Changelog.py

index 674e9e7..b8c10b8 100644 (file)
@@ -126,3 +126,25 @@ class ChangeLog(object):
         Whether this is a native Debian package
         """
         return not '-' in self.version
+
+    @property
+    def author(self):
+        """
+        The author of the last modification
+        """
+        return email.Utils.parseaddr(self._cp['Maintainer'])[0]
+
+    @property
+    def email(self):
+        """
+        The author's email
+        """
+        return email.Utils.parseaddr(self._cp['Maintainer'])[1]
+
+    @property
+    def date(self):
+        """
+        The date of the last modification as rfc822 date
+        """
+        return self._cp['Date']
+
index be22b8a..9048e20 100644 (file)
@@ -170,3 +170,25 @@ def test_parse_name():
     >>> cl.name
     'git-buildpackage'
     """
+
+def test_parse_last_mod():
+    """
+    Test author, email and date of last modification
+
+    Methods tested:
+         - L{gbp.deb.changelog.ChangeLog.__init__}
+
+    Properties tested:
+         - L{gbp.deb.changelog.ChangeLog.name}
+         - L{gbp.deb.changelog.ChangeLog.email}
+         - L{gbp.deb.changelog.ChangeLog.date}
+
+    >>> import gbp.deb.changelog
+    >>> cl = gbp.deb.changelog.ChangeLog(cl_debian)
+    >>> cl.author.startswith('Guido')
+    True
+    >>> cl.email
+    'agx@sigxcpu.org'
+    >>> cl.date
+    'Mon, 17 Oct 2011 10:15:22 +0200'
+    """