aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--climl/__init__.py2
-rw-r--r--climl/hooks.py15
-rw-r--r--climl/interface.py5
3 files changed, 11 insertions, 11 deletions
diff --git a/climl/__init__.py b/climl/__init__.py
index e46baab..8924ebf 100644
--- a/climl/__init__.py
+++ b/climl/__init__.py
@@ -10,7 +10,7 @@ def on_email(content, hooks, conf):
context = dict(
conf=conf,
- rawcontent=content,
+ content=content,
)
try:
diff --git a/climl/hooks.py b/climl/hooks.py
index fcc43f4..a521376 100644
--- a/climl/hooks.py
+++ b/climl/hooks.py
@@ -3,7 +3,7 @@ from . import interface
def hook_extract_listname(context):
- lines = content.split(b'\n')
+ lines = context['content'].split(b'\n')
for line in lines:
print('line: ', line)
if line.startswith(b'Delivered-To: '):
@@ -27,23 +27,18 @@ def hook_process_subscribe_queries(context):
def hook_generate_rcpt_list(context):
- print(1)
listname = context.get('listname', None)
- print(2)
if not listname:
raise interface.HookStopIteration('list name not found')
- print(3)
recipients_filename = ''.join([listname, '-recipents.txt'])
- print(4)
try:
with open(recipients_filename, encoding='utf8') as fi:
recipients = [recipient for recipient in fi]
context['recipients'] = recipients
- print(5)
except FileNotFoundError as e:
n = interface.HookAbortError('recipients list not found')
- n.args.append({'listname': listname,
- 'recipients_filename': recipients_filename})
+ n.args += ({'listname': listname,
+ 'recipients_filename': recipients_filename}, )
raise n from e
@@ -58,5 +53,7 @@ def hook_send_all(context):
smtp_server = smtplib.SMTP(context.conf.get('smtp.server'))
#smtp_server.set_debuglevel(1)
- smtp_server.sendmail(listaddress, context['recipients'], content)
+ smtp_server.sendmail(listaddress,
+ context['recipients'],
+ context['content'])
smtp_server.quit()
diff --git a/climl/interface.py b/climl/interface.py
index 5bafa2b..a42faac 100644
--- a/climl/interface.py
+++ b/climl/interface.py
@@ -3,7 +3,10 @@ This file defines symbols used to make communication between
hooks/plugins/extensions and core of climl.
'''
-class HookError(Exception):
+class Error(Exception):
+ ''' Base class for exceptions in this package '''
+
+class HookError(Error):
'''
Base class for hooks exception, they should not use this directly
'''