<commit_before>
from collections import defaultdict
from inspect import getargspec
from logging import Formatter, StreamHandler, getLogger
from re import match

from gnotty.client import BaseIRCClient
from gnotty.conf import settings


class BaseBot(BaseIRCClient):
    """
    Base bot class. Bots can be built by subclassing ``BaseBot`` and
    using mixins that define event handlers. The subclass itself can
    also implement the event handlers. See the README for more info
    on event handlers.
    """

    class __metaclass__(type):
        def __new__(cls, name, bases, attrs):
            """
            Build a dict mapping event names to their handler methods,
            which are any methods defined on any classes in the
            inheritance heirarchy, that have been marked with an
            "event" attribute, which gets assgined by the
            ``gnotty.bots.events.on`` decorator.
            """
            members = sum([b.__dict__.values() for b in bases], attrs.values())
            attrs["events"] = defaultdict(list)
            for member in members:
                if hasattr(member, "event"):
                    attrs["events"][member.event["name"]].append(member)
            return type.__new__(cls, name, bases, attrs)

    def __init__(self, *args, **kwargs):
        """
        Sets up logging.
        """
        super(BaseBot, self).__init__(*args, **kwargs)
        fmt = Formatter("[%(server)s%(channel)s] %(nickname)s: %(message)s")
        handler = StreamHandler()
        handler.setFormatter(fmt)
        logger = getLogger("irc.message")
        logger.setLevel(settings.LOG_LEVEL)
        logger.addHandler(handler)

    def _dispatcher(self, connection, event):
        """
        This is the method in ``SimpleIRCClient`` that all IRC events
        get passed through. Here we map events to our own custom
        event handlers, and call them.
        """
        super(BaseIRCClient, self)._dispatcher(connection, event)<commit_msg>Fixed DEBUG logging.<commit_after>
from collections import defaultdict
from inspect import getargspec
from logging import Formatter, StreamHandler, getLogger
from re import match

from gnotty.client import BaseIRCClient
from gnotty.conf import settings


class BaseBot(BaseIRCClient):
    """
    Base bot class. Bots can be built by subclassing ``BaseBot`` and
    using mixins that define event handlers. The subclass itself can
    also implement the event handlers. See the README for more info
    on event handlers.
    """

    class __metaclass__(type):
        def __new__(cls, name, bases, attrs):
            """
            Build a dict mapping event names to their handler methods,
            which are any methods defined on any classes in the
            inheritance heirarchy, that have been marked with an
            "event" attribute, which gets assgined by the
            ``gnotty.bots.events.on`` decorator.
            """
            members = sum([b.__dict__.values() for b in bases], attrs.values())
            attrs["events"] = defaultdict(list)
            for member in members:
                if hasattr(member, "event"):
                    attrs["events"][member.event["name"]].append(member)
            return type.__new__(cls, name, bases, attrs)

    def __init__(self, *args, **kwargs):
        """
        Sets up logging.
        """
        super(BaseBot, self).__init__(*args, **kwargs)
        fmt = Formatter("[%(server)s%(channel)s] %(nickname)s: %(message)s")
        handler = StreamHandler()
        handler.setFormatter(fmt)
        logger = getLogger("irc.message")
        logger.setLevel(settings.LOG_LEVEL)
        logger.addHandler(handler)

    def _dispatcher(self, connection, event):
        """
        This is the method in ``SimpleIRCClient`` that all IRC events
        get passed through. Here we map events to our own custom
        event handlers, and call them.
        """
        super(BaseBot, self)._dispatcher(connection, event)
{'fraction_non_alphanumeric': 0.09422644338915272, 'fraction_numerical': 0.0, 'mean_word_length': 2.5105263157894737, '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': '4850190', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1037, 'n_words': 369}