Browse Source

make this error prone

master
Volker Birk 2 years ago
parent
commit
98578d8298
2 changed files with 24 additions and 8 deletions
  1. +22
    -6
      enigmail.py
  2. +2
    -2
      pEp_import.py

+ 22
- 6
enigmail.py View File

@ -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)

+ 2
- 2
pEp_import.py View File

@ -9,8 +9,8 @@ import enigmail
own_pgp_keys = enigmail.own_pgp_keys()
thunderbird_identities = enigmail.thunderbird_identities()
identities = enigmail.identities()
print own_pgp_keys
print
print thunderbird_identities
print identities

Loading…
Cancel
Save