<commit_before># -*- coding: utf-8 -*)
"""
Utility plugins, typically used for debugging and tests.
"""
import logging

from utopia import signals


class RecPlugin(object):
    def __init__(self, terminate_on=None):
        """
        A utility plugin to log messages that occur dugin
        a clients lifetime.

        :param terminate_on: An iterable of commands that will cause the
                             client to terminate when received.
        """
        self.terminate_on = terminate_on or tuple()
        self.received = []

    def bind(self, client):
        signals.on_raw_message.connect(
            self.have_raw_message,
            sender=client
        )
        return self

    def have_raw_message(self, client, prefix, command, args):
        self.received.append((prefix, command, args))

        if command in self.terminate_on:
            client.terminate()

    def did_receive(self, command):
        for prefix, command_recv, args in self.received:
            if command_recv == command:
                return True
        return False


class LogPlugin(object):
    def __init__(self, logger=None):<commit_msg>Typo, uneccesary indentation.<commit_after># -*- coding: utf-8 -*)
"""
Utility plugins, typically used for debugging and tests.
"""
import logging

from utopia import signals


class RecPlugin(object):
    def __init__(self, terminate_on=None):
        """
        A utility plugin to log messages that occur during a clients lifetime.

        :param terminate_on: An iterable of commands that will cause the
                             client to terminate when received.
        """
        self.terminate_on = terminate_on or tuple()
        self.received = []

    def bind(self, client):
        signals.on_raw_message.connect(
            self.have_raw_message,
            sender=client
        )
        return self

    def have_raw_message(self, client, prefix, command, args):
        self.received.append((prefix, command, args))

        if command in self.terminate_on:
            client.terminate()

    def did_receive(self, command):
        for prefix, command_recv, args in self.received:
            if command_recv == command:
                return True
        return False


class LogPlugin(object):
    def __init__(self, logger=None):
{'fraction_non_alphanumeric': 0.08380129589632829, 'fraction_numerical': 0.0008639308855291577, 'mean_word_length': 2.2436974789915967, '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': '4001732', 'n_tokens_mistral': 630, 'n_tokens_neox': 597, 'n_words': 195}