From 95b8a77e7782266978c986a2e2fd9bce94e27300 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 7 Apr 2017 16:01:11 +0300 Subject: refactor: Make _find_tickets_... get context --- distixlib/plugins/import_mail_plugin.py | 17 ++++++++--------- 1 file 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) -- cgit v1.2.1