Skip to content

Commit

Permalink
notification: check pyxarf module presence with variable
Browse files Browse the repository at this point in the history
instead of querying sys.modules directly
  • Loading branch information
wagner-intevation committed Jun 10, 2022
1 parent 5e6f79c commit 683ff0b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions intelmqmail/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
import os
import tempfile
import datetime
import sys

# if we have the optional module pyxarf, we can define more methods
try:
import pyxarf
except ModuleNotFoundError:
pass
pyxarf = None

from intelmqmail.db import load_events, new_ticket_number, mark_as_sent
from intelmqmail.templates import read_template
Expand Down Expand Up @@ -307,7 +306,7 @@ def mail_format_as_csv(self, format_spec, template=None,
attachments=attachments, gpgme_ctx=self.gpgme_ctx)
return [EmailNotification(self.directive, mail, ticket)]

if "pyxarf" in sys.modules:
if pyxarf:
def mail_format_as_xarf(self, xarf_schema): # noqa
"""Create Messages in X-Arf Format
Expand Down Expand Up @@ -372,7 +371,7 @@ def mail_format_as_xarf(self, xarf_schema): # noqa

return returnlist_notifications

if "pyxarf" in sys.modules:
if pyxarf:
def create_xarf_mail(self, subject, body, xarf_object): # noqa
"""
Expand Down

0 comments on commit 683ff0b

Please sign in to comment.