[Pgp-tools-commit] r665 - trunk/keyart
Aaron Toponce
atoponce-guest at moszumanska.debian.org
Wed Jun 18 21:11:24 UTC 2014
Author: atoponce-guest
Date: 2014-06-18 21:11:24 +0000 (Wed, 18 Jun 2014)
New Revision: 665
Modified:
trunk/keyart/keyart
Log:
Add arbitrary hex support and change options.
Now keyart(1) can be called with '-f|--fingerprint' and a random hexadecimal
string, regardless if that hex string is in a public keyring or not.
Also change '-f|--file' to '-k|--keyring' as that is more fitting for what it
really is.
Modified: trunk/keyart/keyart
===================================================================
--- trunk/keyart/keyart 2014-06-18 17:29:35 UTC (rev 664)
+++ trunk/keyart/keyart 2014-06-18 21:11:24 UTC (rev 665)
@@ -12,9 +12,12 @@
description='Creates ASCII art from OpenPGP keys.')
PARSER.add_argument('-c', '--color', help='Print the art with ANSI color.',
action='store_true')
-PARSER.add_argument('-f', '--file', type=str, metavar=('FILE'),
+PARSER.add_argument('-k', '--keyring', type=str, metavar=('KEYRING'),
action='append',
help='A publicly exported OpenPGP key or keyring.')
+PARSER.add_argument('-f', '--fingerprint', type=str, metavar=('FINGERPRINT'),
+ action='append',
+ help='A hexadecimal string representing a fingerprint.')
PARSER.add_argument('keyid', type=str, nargs='*', metavar=('KEYID'),
help='A key identifier (email, ID, fingerprint, etc.).')
ARGS = PARSER.parse_args()
@@ -153,7 +156,11 @@
else:
key_algo = 'N/A'
- header = "["+key_algo+" "+key_size+"]"
+ if key_size:
+ header = "["+key_algo+" "+key_size+"]"
+ else:
+ header = ''
+
if len(header) > 19:
header = ''
art += '+{:-^19}+\n'.format(header)
@@ -216,26 +223,39 @@
coin = coins[num_of_hits]
return '{}{}{}'.format(color, coin, reset)
+def gpg_cmd(cmd):
+ gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ for lines in gpg.communicate()[0].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])
+ size = None
+ algo = None
+
if __name__ == '__main__':
gpg_bin = test_env()
cmd = [gpg_bin, '--with-colons', '--fingerprint']
- if ARGS.file:
+ if ARGS.fingerprint:
+ size = None
+ algo = None
+ fpr = ARGS.fingerprint[0]
+ print draw_art(size, algo, fpr)
+
+ if ARGS.keyring:
cmd.append('--no-default-keyring')
- cmd.extend(['--keyring=%s' % os.path.abspath(keyring) for keyring in
- ARGS.file])
+ cmd.extend(['--keyring=%s' % os.path.abspath(keyring)
+ for keyring in ARGS.keyring])
+ gpg_cmd(cmd)
if ARGS.keyid:
cmd.append('--')
cmd.extend(ARGS.keyid)
+ gpg_cmd(cmd)
- gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- for lines in gpg.communicate()[0].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])
- size = None
- algo = None
+
+
+
More information about the Pgp-tools-commit
mailing list