telepathy-idle: tools/make-release-mail: Update from telepathy-glib (fix for python 3)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Oct 31 23:12:17 UTC 2020


Module: telepathy-idle
Branch: master
Commit: c9b6a16206dd25c37ea3fc43f2b8870bfe410e52
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=c9b6a16206dd25c37ea3fc43f2b8870bfe410e52

Author: Alexander Akulich <akulichalexander at gmail.com>
Date:   Sun Nov  1 01:33:47 2020 +0300

tools/make-release-mail: Update from telepathy-glib (fix for python 3)

---

 tools/make-release-mail.py | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/tools/make-release-mail.py b/tools/make-release-mail.py
index 5c42b47..3343838 100644
--- a/tools/make-release-mail.py
+++ b/tools/make-release-mail.py
@@ -6,6 +6,15 @@
 # to <telepathy at lists.freedesktop.org>. I hope that you enjoy your stay.
 
 import sys
+import re
+
+def looks_like_a_header(line, package, version=None):
+    if version is None:
+        pattern = "^%s .* \(.*\)$" % package
+    else:
+        pattern = "^%s %s \(.*\)$" % (package, version)
+
+    return re.match(pattern, line) is not None
 
 def extract_description(package, version, news_path):
     release_name = []
@@ -15,19 +24,19 @@ def extract_description(package, version, news_path):
         lines = (line for line in f.readlines())
         for line in lines:
             # Find the 'telepathy-foo 0.1.2' header
-            if line.startswith("%s %s" % (package, version)):
+            if looks_like_a_header(line, package, version):
                 break
 
         # Skip the ====== line, and the first blank line
-        lines.next()
-        lines.next()
+        next(lines)
+        next(lines)
 
         got_release_name = False
 
         for line in lines:
             line = line.rstrip()
             # If we hit the next version header, we're done
-            if line.startswith(package):
+            if looks_like_a_header(line, package):
                 break
             # Else, if we hit a blank line and we're still reading the release
             # name, we're done with the release name.
@@ -50,7 +59,7 @@ GIT_URL = 'http://cgit.freedesktop.org/telepathy'
 def main(package, version, news_path):
     release_name, details = extract_description(package, version, news_path)
 
-    print """
+    print("""
 %(release_name)s
 
 tarball: %(base_url)s/%(package)s/%(package)s-%(version)s.tar.gz
@@ -64,14 +73,14 @@ git: %(git_url)s/%(package)s
         'version': version,
         'release_name': release_name,
         'details': details,
-    }
+    })
 
 if __name__ == '__main__':
     try:
         package, version, news_path = sys.argv[1:]
 
         main(package, version, news_path)
-    except ValueError, e:
+    except ValueError as e:
         sys.stderr.write(
             'Usage: %s package-name package.version.number path/to/NEWS\n' %
             sys.argv[0])



More information about the telepathy-commits mailing list