<commit_before>from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType

from . import updaters

try:
    from multiprocessing import Process
except ImportError:
    # Not 2.6 so use threads instead
    from threading import Thread as Process


class Manager(models.Model):
    user = models.OneToOneField(User)

    def __str__(self):
        return self.user.username

    def send(self, message):
        for relation in dir(self):
            if relation.endswith('updater'):
                updater = getattr(self, relation)
                p = Process(target=updater.send, args=(message,))
                p.start()


class Observer(models.Model):
    manager = models.ForeignKey(Manager)
    subject = models.ForeignKey(ContentType)
    message = models.CharField(max_length=200)
    active = models.BooleanField()

    def __str__(self):
        return '%s: %s' % (self.manager, self.subject)

    def send(self, instance):
        self.manager.send(self.message % vars(instance))


class Updater(models.Model):
    manager = models.OneToOneField(Manager)
    username = models.CharField(max_length=100)
    password = models.CharField(max_length=200)
    updater = models.CharField(max_length=100, choices=updaters.choices())

    def __str__(self):
        return str(self.manager)

    def send(self, message):
        self.updater(self.username, self.password, message)
<commit_msg>Switched send to call correct function<commit_after>from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType

from . import updaters

try:
    from multiprocessing import Process
except ImportError:
    # Not 2.6 so use threads instead
    from threading import Thread as Process


class Manager(models.Model):
    user = models.OneToOneField(User)

    def __str__(self):
        return self.user.username

    def send(self, message):
        for relation in dir(self):
            if relation.endswith('updater'):
                updater = getattr(self, relation)
                p = Process(target=updater.send, args=(message,))
                p.start()


class Observer(models.Model):
    manager = models.ForeignKey(Manager)
    subject = models.ForeignKey(ContentType)
    message = models.CharField(max_length=200)
    active = models.BooleanField()

    def __str__(self):
        return '%s: %s' % (self.manager, self.subject)

    def send(self, instance):
        self.manager.send(self.message % vars(instance))


class Updater(models.Model):
    manager = models.OneToOneField(Manager)
    username = models.CharField(max_length=100)
    password = models.CharField(max_length=200)
    updater = models.CharField(max_length=100, choices=updaters.choices())

    def __str__(self):
        return str(self.manager)

    def send(self, message):
        updaters[self.updater](self.username, self.password, message)

{'fraction_non_alphanumeric': 0.10158089471913892, 'fraction_numerical': 0.009418096199125462, 'mean_word_length': 3.2607449856733526, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4378954', 'n_tokens_mistral': 891, 'n_tokens_neox': 854, 'n_words': 207}