<commit_before>from email.mime.image import MIMEImage

from django.contrib.staticfiles import finders
from .base import EmailBase


class PlatformEmailMixin:
    """
    Attaches the static file images/logo.png so it can be used in an html
    email.
    """
    def get_attachments(self):
        attachments = super().get_attachments()
        filename = finders.find('images/email_logo.png')
        if filename:
            f = open(filename, 'rb')
            logo = MIMEImage(f.read())
            logo.add_header('Content-ID', '<{}>'.format('logo'))
            return attachments + [logo]
        return attachments


class SyncEmailMixin(EmailBase):
    """Send Emails synchronously."""

    @classmethod
    def send(cls, object, *args, **kwargs):
        """Call dispatch immediately"""
        return cls().dispatch(object, *args, **kwargs)<commit_msg>Allow svg as email logo attachment<commit_after>from email.mime.image import MIMEImage

from django.contrib.staticfiles import finders
from .base import EmailBase


class PlatformEmailMixin:
    """
    Attaches the static file images/logo.png so it can be used in an html
    email.
    """
    def get_attachments(self):
        attachments = super().get_attachments()
        filename = (
            finders.find('images/email_logo.png')
            or finders.find('images/email_logo.svg')
        )
        if filename:
            f = open(filename, 'rb')
            logo = MIMEImage(f.read())
            logo.add_header('Content-ID', '<{}>'.format('logo'))
            return attachments + [logo]
        return attachments


class SyncEmailMixin(EmailBase):
    """Send Emails synchronously."""

    @classmethod
    def send(cls, object, *args, **kwargs):
        """Call dispatch immediately"""
        return cls().dispatch(object, *args, **kwargs)
{'fraction_non_alphanumeric': 0.11993428258488499, 'fraction_numerical': 0.0, 'mean_word_length': 2.7058823529411766, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3799333', 'n_tokens_mistral': 515, 'n_tokens_neox': 503, 'n_words': 138}