Browse Source

support export

master
Volker Birk 2 years ago
parent
commit
6e36c9e498
1 changed files with 18 additions and 2 deletions
  1. +18
    -2
      gnupg.py

+ 18
- 2
gnupg.py View File

@ -24,7 +24,7 @@ gpg = gpg_executable(thunderbird_base)
def command(*args):
result = []
cmd = [gpg, '--with-colons']
cmd = [gpg, '--with-colons', '--batch']
cmd.extend(args)
for line in Popen(cmd, stdout=PIPE).stdout:
data = line.split(':')
@ -32,8 +32,15 @@ def command(*args):
return result
def export_command(*args):
result = ""
cmd = [gpg, '-a', '--batch']
cmd.extend(args)
return "".join(Popen(cmd, stdout=PIPE).stdout.readlines())
def fpr_from_keyid(keyid):
for x in command('--fingerprint', 'A9E44CABD4F2EF04'):
for x in command('--fingerprint', keyid):
if x[0] == 'fpr':
return x[9]
raise LookupError()
@ -41,3 +48,12 @@ def fpr_from_keyid(keyid):
def own_keys():
return [ fpr_from_keyid(x[4]) for x in command('-K') if x[0] == 'sec' and x[1] == 'u' ]
def keydata(fpr):
return export_command('--export', fpr)
def secret(fpr):
return export_command('--export-secret-key', fpr)

Loading…
Cancel
Save