[Yum-devel] [PATCH 1/3] Add helper function to access the fingerprint in the GPG key info data.

James Antill james at and.org
Thu Oct 13 14:39:21 UTC 2011


---
 yum/misc.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/yum/misc.py b/yum/misc.py
index 04490a6..5321003 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -8,6 +8,7 @@ import os
 import os.path
 from cStringIO import StringIO
 import base64
+import binascii
 import struct
 import re
 import errno
@@ -410,6 +411,17 @@ def procgpgkey(rawkey):
     # Decode and return
     return base64.decodestring(block.getvalue())
 
+def gpgkey_fingerprint_ascii(info, chop=4):
+    ''' Given a key_info data from getgpgkeyinfo(), return an ascii
+    fingerprint. Chop every 4 ascii values, as that is what GPG does. '''
+    # First "duh" ... it's a method...
+    fp = info['fingerprint']()
+    fp = binascii.hexlify(fp)
+    if chop:
+        fp = [fp[i:i+chop] for i in range(0, len(fp), chop)]
+        fp = " ".join(fp)
+    return fp
+
 def getgpgkeyinfo(rawkey, multiple=False):
     '''Return a dict of info for the given ASCII armoured key text
 
-- 
1.7.6.4



More information about the Yum-devel mailing list