initial structure

master
Volker Birk 2 years ago
parent 1b79c29776
commit 0e52011c93
  1. 2
      .gitignore
  2. 22
      common.py
  3. 22
      pEp_import.py
  4. 3
      platform_Linux.py
  5. 3
      platform_Windows.py
  6. 9
      platform_macOS.py
  7. 33
      thunderbird.py
  8. 15
      unix.py

2
.gitignore vendored

@ -129,3 +129,5 @@ dmypy.json
# Pyre type checker
.pyre/
ws

@ -0,0 +1,22 @@
# coding=UTF-8
import os
class GnuPGNotFound(LookupError):
pass
def which(program):
fpath, fname = os.path.split(program)
if fpath:
if os.path.isfile(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if os.path.isfile(exe_file):
return exe_file
return None

@ -0,0 +1,22 @@
# coding=UTF-8
import sys
if sys.platform == 'darwin':
from platform_macOS import *
elif sys.platform == 'win32':
from platform_Windows import *
elif sys.platform == 'linux':
from platform_Linux import *
else:
sys.stderr.write("this program is platform dependent\n")
sys.exit(1)
gpg = gpg_executable(thunderbird_base)
print(gpg)

@ -0,0 +1,3 @@
# coding=UTF-8

@ -0,0 +1,3 @@
# coding=UTF-8

@ -0,0 +1,9 @@
# coding=UTF-8
from os import environ
from unix import *
thunderbird_base = environ['HOME'] + '/Library/Thunderbird'

@ -0,0 +1,33 @@
# coding=UTF-8
import os
class ThunderbirdNotFound(LookupError):
pass
def profile_path(thunderbird_base):
from configparser import ConfigParser
config = ConfigParser()
filename = os.path.join(thunderbird_base, 'profiles.ini')
config.read(filename)
for section in config:
try:
if config.get(section, 'Name') == 'default-release':
return os.path.join(thunderbird_base, config.get(section, 'Path'))
except: pass
raise ThunderbirdNotFound()
def enigmail_agentPath(thunderbird_base):
from fileinput import input
import re
c = re.compile(r'user_pref\(["\']extensions\.enigmail\.agentPath["\'],\s*["\'](?P<path>[^"\']*)["\']\);')
filename = os.path.join(profile_path(thunderbird_base), 'prefs.js')
for line in input(files=(filename,)):
m = c.search(line)
if m:
return m.group('path')
return None

@ -0,0 +1,15 @@
# coding=UTF-8
from thunderbird import enigmail_agentPath
from common import which, GnuPGNotFound
def gpg_executable(thunderbird_base):
enigmail_gpg = enigmail_agentPath(thunderbird_base)
gpg2 = enigmail_gpg if enigmail_gpg else which('gpg2')
gpg = gpg2 if gpg2 else which('gpg')
if not gpg:
raise GnuPGNotFound()
else:
return gpg
Loading…
Cancel
Save