|
|
@ -3,6 +3,8 @@ |
|
|
|
|
|
|
|
import sys |
|
|
|
import fileinput |
|
|
|
import thunderbird |
|
|
|
import re |
|
|
|
from subprocess import Popen, PIPE |
|
|
|
|
|
|
|
|
|
|
@ -50,17 +52,32 @@ def own_keys(): |
|
|
|
return [ fpr_from_keyid(x[4]) for x in command('-K') if x[0] == 'sec' and x[1] == 'u' ] |
|
|
|
|
|
|
|
|
|
|
|
uid_re = re.compile(r'(?P<name>[^<]*) \<(?P<email>[^>]*)\>') |
|
|
|
|
|
|
|
|
|
|
|
def uid(text): |
|
|
|
m = uid_re.match(text) |
|
|
|
if m: |
|
|
|
return { 'name': m.group('name'), 'email': m.group('email') } |
|
|
|
raise LookupError() |
|
|
|
|
|
|
|
|
|
|
|
def own_pgp_keys(): |
|
|
|
result = [] |
|
|
|
key = {} |
|
|
|
for x in command('-K'): |
|
|
|
if x[0] == 'sec' and x[1] == 'u': |
|
|
|
key = { 'fpr': fpr_from_keyid(x[4]) , 'uids': [] } |
|
|
|
result.append(key) |
|
|
|
try: |
|
|
|
key = { 'fpr': fpr_from_keyid(x[4]) , 'uids': [] } |
|
|
|
result.append(key) |
|
|
|
except LookupError: |
|
|
|
key = { 'uids': [] } |
|
|
|
elif x[0] == 'sec': |
|
|
|
key = { 'uids': [] } |
|
|
|
elif x[0] == 'uid': |
|
|
|
key['uids'].append(x[9]) |
|
|
|
try: |
|
|
|
key['uids'].append(uid(x[9])) |
|
|
|
except LookupError: pass |
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
@ -72,7 +89,6 @@ def secret(fpr): |
|
|
|
return export_command('--export-secret-key', fpr) |
|
|
|
|
|
|
|
|
|
|
|
def thunderbird_identities(): |
|
|
|
from thunderbird import identities |
|
|
|
return identities(thunderbird_base) |
|
|
|
def identities(): |
|
|
|
return thunderbird.identities(thunderbird_base) |
|
|
|
|