[Pgp-tools-commit] r682 - trunk/keyart

Aaron Toponce atoponce-guest at moszumanska.debian.org
Wed Jul 9 01:58:30 UTC 2014


Author: atoponce-guest
Date: 2014-07-09 01:58:30 +0000 (Wed, 09 Jul 2014)
New Revision: 682

Modified:
   trunk/keyart/keyart
Log:
make keyart both python2 and python3 compatible

Modified: trunk/keyart/keyart
===================================================================
--- trunk/keyart/keyart	2014-07-08 14:39:20 UTC (rev 681)
+++ trunk/keyart/keyart	2014-07-09 01:58:30 UTC (rev 682)
@@ -31,7 +31,7 @@
             gnupg = '/usr/bin/gpg2'
         return gnupg
     except OSError:
-        print "Please install GnuPG before using this script."
+        print("Please install GnuPG before using this script.")
         sys.exit(1)
 
 def draw_art(key_size, key_algo, key_fpr):
@@ -46,7 +46,7 @@
     try:
         key_bin = bin(int(key_fpr, 16))[2:].zfill(len(key_fpr)*4)
     except ValueError:
-        print "The supplied fingerprint is not a hexadecimal string."
+        print("The supplied fingerprint is not a hexadecimal string.")
         sys.exit(3)
 
     for i, char in enumerate(key_bin):
@@ -56,7 +56,7 @@
             temp = ''
 
     # create a little-endian bit-pair array
-    for i in xrange(0, len(f_bytes), 4):
+    for i in range(0, len(f_bytes), 4):
         f_bytes[i], f_bytes[i+3] = f_bytes[i+3], f_bytes[i]
         f_bytes[i+1], f_bytes[i+2] = f_bytes[i+2], f_bytes[i+1]
 
@@ -167,7 +167,7 @@
 
     if len(header) > 19:
         header = ''
-    art += '+' + str.center(header, 19, '-') + '+\n'
+    art += '+' + header.center(19, '-') + '+\n'
 
     for i, visit in enumerate(visits):
         # Build up the art with the boundaries and newlines
@@ -187,11 +187,11 @@
             art = art.format(_get_coin(visit, ARGS.color))
 
     if key_size:
-        footer = "["+key_fpr[-8:]+"]"
+        footer = "["+key_fpr[-16:]+"]"
     else:
         footer = ''
 
-    art += '+' + str.center(footer, 19, '-') + '+'
+    art += '+' + footer.center(19, '-') + '+'
 
     return art
 
@@ -235,13 +235,13 @@
 
 def gpg_cmd(cmd):
     gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
-    for lines in gpg.communicate()[0].split('\n'):
+    for lines in gpg.communicate()[0].decode('ascii').split('\n'):
         colons = lines.split(':')
         if colons[0] == 'pub':
             size = colons[2]
             algo = colons[3]
         elif colons[0] == 'fpr':
-            print draw_art(size, algo, colons[9])
+            print(draw_art(size, algo, colons[9]))
             size = None
             algo = None
 
@@ -252,9 +252,9 @@
     if ARGS.fingerprint:
         for fpr in ARGS.fingerprint:
             if len(fpr) % 8 != 0:
-                print "Hex string must be a multiple of 8 bytes."
+                print("Hex string must be a multiple of 8 bytes.")
                 sys.exit(2)
-            print draw_art(None, None, fpr)
+            print(draw_art(None, None, fpr))
 
     if ARGS.keyring:
         cmd.append('--no-default-keyring')




More information about the Pgp-tools-commit mailing list