Browse Source

evaluate rules

master
Volker Birk 2 years ago
parent
commit
11e1aae3dd
2 changed files with 23 additions and 1 deletions
  1. +21
    -1
      enigmail.py
  2. +2
    -0
      pEp_import.py

+ 21
- 1
enigmail.py View File

@ -2,6 +2,7 @@
import sys
import os
import thunderbird
import re
from subprocess import Popen, PIPE
@ -101,8 +102,27 @@ def pubkey_iterator():
class Rules:
def __init__(self):
try:
self.et = ET.parse(os.path.join(profile_path(thunderbird_base), 'pgprules.xml'))
self.et = ET.parse(os.path.join(thunderbird.profile_path(thunderbird_base), 'pgprules.xml'))
self.rules = self.et.getroot()
except:
self.et = None
self.rules = None
def test_address(self, email):
if self.rules is None:
return True
result = True
for rule in self.rules:
if rule.attrib['email'][0] == '{' and rule.attrib['email'][-1] == '}':
if email == rule.attrib['email'][1:-1]:
result = rule.attrib['encrypt'] != '0'
if rule.attrib['keyId'] == '.':
break
elif len(rule.attrib['keyId']) > 2:
return rule.attrib['keyId'][2:]
return result
rules = Rules()

+ 2
- 0
pEp_import.py View File

@ -20,3 +20,5 @@ with pEp_JSON.Connection() as connect:
pass
print thunderbird.enigmail_assignKeysByEmailAddr(thunderbird_base)
print enigmail.rules.test_address("vb@pibit.ch")

Loading…
Cancel
Save