subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danie...@apache.org
Subject svn commit: r1800544 - /subversion/trunk/tools/dist/release.py
Date Sun, 02 Jul 2017 05:32:59 GMT
Author: danielsh
Date: Sun Jul  2 05:32:59 2017
New Revision: 1800544

URL: http://svn.apache.org/viewvc?rev=1800544&view=rev
Log:
release.py: Cosmetic change in preparation for following patches.

* tools/dist/release.py
  (fp_pattern): Name the match groups.
  (get_siginfo): Use names rather than magic numbers.

Modified:
    subversion/trunk/tools/dist/release.py

Modified: subversion/trunk/tools/dist/release.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dist/release.py?rev=1800544&r1=1800543&r2=1800544&view=diff
==============================================================================
--- subversion/trunk/tools/dist/release.py (original)
+++ subversion/trunk/tools/dist/release.py Sun Jul  2 05:32:59 2017
@@ -824,7 +824,7 @@ def write_downloads(args):
 # Validate the signatures for a release
 
 key_start = '-----BEGIN PGP SIGNATURE-----'
-fp_pattern = re.compile(r'^pub\s+(\w+\/\w+)[^\n]*\n\s+Key\sfingerprint\s=((\s+[0-9A-F]{4}){10})\nuid\s+([^<\(]+)\s')
+fp_pattern = re.compile(r'^pub\s+(?P<length_and_type>\w+\/\w+)[^\n]*\n\s+Key\sfingerprint\s=(?P<fingerprint>(\s+[0-9A-F]{4}){10})\nuid\s+(?P<name_and_comment>[^<\(]+)\s')
 
 def get_siginfo(args, quiet=False):
     'Returns a list of signatures for the release.'
@@ -867,6 +867,9 @@ def get_siginfo(args, quiet=False):
         # Most potential signers have public short keyid (32-bit) collisions in
         # the https://evil32.com/ set, which has been uploaded to the
         # keyservers, so generate the long keyid.
+        #
+        # NOTE: The following code assumes that 'gpg' is a gpg1 binary.  gpg2
+        # produces different output.
         gpg = subprocess.Popen(['gpg', '--keyid-format', 'long', '--fingerprint', id],
                                stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
         rc = gpg.wait()
@@ -879,13 +882,17 @@ def get_siginfo(args, quiet=False):
         gpg_output = "\n".join([ l for l in gpg_output.splitlines()
                                                      if l[0:7] != 'Warning' ])
 
-        fp = fp_pattern.match(gpg_output).groups()
-        fingerprints["%s [%s] %s" % (fp[3], fp[0], fp[1])] = fp
-
-    for entry in sorted(fingerprints.keys()):
-        fp = fingerprints[entry]
-        output.append("   %s [%s] with fingerprint:" % (fp[3], fp[0]))
-        output.append("   %s" % fp[1])
+        match = fp_pattern.match(gpg_output)
+        format_expandos = dict(
+            name=match.group('name_and_comment'),
+            length_and_type=match.group('length_and_type'),
+            fingerprint=match.group('fingerprint'),
+        )
+        # The {fingerprint} match group starts with a single whitespace.
+        line = "   {name} [{length_and_type}] with fingerprint:"
+        output.append( line.format(**format_expandos) )
+        line = "   {fingerprint}"
+        output.append( line.format(**format_expandos) )
 
     return output
 



Mime
View raw message