<commit_before>from email import message
from email import utils
from five import grok
from tn.plonemailing import interfaces
from zope.component import getMultiAdapter

import quopri
import email.header
import os
import random
import re
import time


class BaseMessageFactory(object):
    def __init__(self, context, request, newsletter, subscriber):
        self.context    = context
        self.request    = request
        self.newsletter = newsletter
        self.subscriber = subscriber

    def __call__(self, content):
        msg = build_message_root(self.newsletter, self.subscriber)
        self._configure_message(msg, content)
        add_message_id(msg)
        return message


class TextMessageFactory(grok.MultiAdapter, BaseMessageFactory):
    grok.adapts(None, None, interfaces.INewsletter, interfaces.ISubscriber)
    grok.implements(interfaces.IMessageFactory)
    grok.name(u'text')

    def _configure_message(self, message, content):
        configure_text_message(self.context,
                               self.request,
                               self.newsletter,
                               message,
                               content)


class MultipartMessageFactory(grok.MultiAdapter, BaseMessageFactory):
    grok.adapts(None, None, interfaces.INewsletter, interfaces.ISubscriber)
    grok.implements(interfaces.IMessageFactory)
    grok.name(u'__multipart__')

    def _configure_message(self, message, content):
        configure_multipart_message(self.context,
                                    self.request,
                                    self.newsletter,
                                    self.subscriber,
                                    message,
                                    content)


@grok.adapter(None, None, interfaces.INewsletter, interfaces.ISubscriber,
              name=u'html')<commit_msg>Fix message factory (module shadowing local method parameter)<commit_after>from email import message
from email import utils
from five import grok
from tn.plonemailing import interfaces
from zope.component import getMultiAdapter

import quopri
import email.header
import os
import random
import re
import time


class BaseMessageFactory(object):
    def __init__(self, context, request, newsletter, subscriber):
        self.context    = context
        self.request    = request
        self.newsletter = newsletter
        self.subscriber = subscriber

    def __call__(self, content):
        msg = build_message_root(self.newsletter, self.subscriber)
        self._configure_message(msg, content)
        add_message_id(msg)
        return message


class TextMessageFactory(grok.MultiAdapter, BaseMessageFactory):
    grok.adapts(None, None, interfaces.INewsletter, interfaces.ISubscriber)
    grok.implements(interfaces.IMessageFactory)
    grok.name(u'text')

    def _configure_message(self, msg, content):
        configure_text_message(self.context,
                               self.request,
                               self.newsletter,
                               msg,
                               content)


class MultipartMessageFactory(grok.MultiAdapter, BaseMessageFactory):
    grok.adapts(None, None, interfaces.INewsletter, interfaces.ISubscriber)
    grok.implements(interfaces.IMessageFactory)
    grok.name(u'__multipart__')

    def _configure_message(self, msg, content):
        configure_multipart_message(self.context,
                                    self.request,
                                    self.newsletter,
                                    self.subscriber,
                                    msg,
                                    content)


@grok.adapter(None, None, interfaces.INewsletter, interfaces.ISubscriber,
              name=u'html')
{'fraction_non_alphanumeric': 0.06790450928381962, 'fraction_numerical': 0.0, 'mean_word_length': 2.147746243739566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2351024', 'n_tokens_mistral': 989, 'n_tokens_neox': 939, 'n_words': 208}