summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-07 16:01:11 +0300
committerLars Wirzenius <liw@liw.fi>2017-04-07 16:01:11 +0300
commit95b8a77e7782266978c986a2e2fd9bce94e27300 (patch)
treedae0050d7a08ff9396558caf5ff060dd40792cb4
parentec242842d41fde4bb9e9e18086df670c600b2397 (diff)
downloaddistix-95b8a77e7782266978c986a2e2fd9bce94e27300.tar.gz
refactor: Make _find_tickets_... get context
-rw-r--r--distixlib/plugins/import_mail_plugin.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/distixlib/plugins/import_mail_plugin.py b/distixlib/plugins/import_mail_plugin.py
index 6a44223..fcce23a 100644
--- a/distixlib/plugins/import_mail_plugin.py
+++ b/distixlib/plugins/import_mail_plugin.py
@@ -126,7 +126,7 @@ class ImportMailPlugin(cliapp.Plugin):
self, context, msg, key, value):
referenced_ids = self._find_tickets_with_mails_referenced_by_msg(
- context.store, context.all_ticket_ids, msg, context.cache)
+ context, msg)
msg_ids = distixlib.get_ids_from_message(msg)
filenames = []
@@ -169,22 +169,21 @@ class ImportMailPlugin(cliapp.Plugin):
return True
return False
- def _find_tickets_with_mails_referenced_by_msg(
- self, store, all_ticket_ids, msg, cache):
-
+ def _find_tickets_with_mails_referenced_by_msg(self, context, msg):
ticket_ids = []
msg_ids = distixlib.get_ids_from_message(msg)
- for ticket_id in all_ticket_ids:
- if ticket_id in cache:
- other_ids = cache.get_msg_ids_for_ticket_id(ticket_id)
+ for ticket_id in context.all_ticket_ids:
+ if ticket_id in context.cache:
+ other_ids = contex.cache.get_msg_ids_for_ticket_id(ticket_id)
else:
- filenames = store.get_message_filenames(ticket_id)
+ filenames = context.store.get_message_filenames(ticket_id)
for filename in filenames:
with open(filename) as f:
other_msg = email.message_from_file(f)
other_ids = distixlib.get_ids_from_message(other_msg)
- cache.add_msg_ids_for_ticket_id(ticket_id, other_ids)
+ context.cache.add_msg_ids_for_ticket_id(
+ ticket_id, other_ids)
if other_ids.intersection(msg_ids):
ticket_ids.append(ticket_id)