Import data from Enigmail to pEp for Thunderbird
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2 KiB

# coding=UTF-8
import os
import re
from fileinput import input
class ThunderbirdNotFound(LookupError):
def profile_path(thunderbird_base):
from ConfigParser import SafeConfigParser
config = SafeConfigParser()
filename = os.path.join(thunderbird_base, 'profiles.ini')
for section in config.sections():
if config.get(section, 'Name') == 'default-release':
return os.path.join(thunderbird_base, config.get(section, 'Path'))
except: pass
raise ThunderbirdNotFound()
def prefs(thunderbird_base, key):
c = re.compile(r'user_pref\(["\']' + key + '["\'],\s*["\']?(?P<value>[^"\']*)["\']?\);', re.UNICODE)
filename = os.path.join(profile_path(thunderbird_base), 'prefs.js')
finput = input(files=(filename,))
for line in finput:
m =
if m:
return None
def enigmail_agentPath(thunderbird_base):
return prefs(thunderbird_base, r'extensions\.enigmail\.agentPath')
def enigmail_juniorMode(thunderbird_base):
result = prefs(thunderbird_base, r'extensions\.enigmail\.juniorMode')
if result == '0':
return False
return True
def enigmail_assignKeysByRules(thunderbird_base):
result = prefs(thunderbird_base, r'extensions\.enigmail\.assignKeysByRules')
if result == 'false':
return False
return True
def enigmail_assignKeysByEmailAddr(thunderbird_base):
result = prefs(thunderbird_base, r'extensions\.enigmail\.assignKeysByEmailAddr')
if result == 'false':
return False
return True
def identities(thunderbird_base):
result = {}
c = re.compile(r'user_pref\(["\']mail\.identity\.(?P<name>\w+)\.(?P<field>\w+)["\'],\s*["\'](?P<value>[^"\']*)["\']\);', re.UNICODE)
filename = os.path.join(profile_path(thunderbird_base), 'prefs.js')
for line in input(files=(filename,)):
m =
if m:
if not'name') in result:
result['name')] = {}
result['name')]['field')] ='value')
return result