<commit_before># -*- coding: utf-8 -*-
# vim: set ts=4 et

import bisect
import inspect
import re
import traceback

url_re = re.compile(
  'https?://[^ /]+\.[^ /]+(?:/[^ ]*)?'  +
  '|'                                   +
  '(?<![^ ])[^ /]+\.[^ /]+/[^ ]*'
)

domain_re = re.compile('https?://(?:www\.)?([^ /]+\.[^ /]+)')

from message import Message

class Hook(object):
    def __init__(self, sort, extra={}):
        self.sort = sort
        self.extra = extra

    def __call__(self, *args):
        if not hasattr(self, 'fn'):
            Exception('attempt to call an unbound hook')
            return

        try:
            return self.fn(*args[:self.nargs])
        except:
            print('%s hook error:' % type(self))
            traceback.print_exc()

    def __lt__(self, other):
        return self.sort < other.sort

    def bind(self, fn, owner=None):
        if owner:
            self.owner = owner
        elif hasattr(fn, '__class__'):
            self.owner = fn.__class__
        else:
            raise Exception('unable to bind hook, no owner!')
        self.fn = fn

        if inspect.ismethod(fn):
            self.nargs = self.fn.__func__.__code__.co_argcount - 1
            self.__func__ = self.fn.__func__
        else:
            self.nargs = self.fn.__code__.co_argcount
            self.__func__ = self.fn

        if not hasattr(self.__func__, '_priority'):
            self.__func__._priority = getattr(self.owner, 'default_priority', 500)
        
        if not hasattr(self.__func__, '_level'):
            self.__func__._level = getattr(self.owner, 'default_level', 1)

class EventHook(Hook):
    def __init__(self, event):
        Hook.__init__(self, event)

class CommandHook(Hook):
    def __init__(self, command):
        Hook.__init__(self, command.upper())

class TriggerHook(Hook):
    def __init__(self, trigger):<commit_msg>fixed stupid bug where hooks don't unload properly<commit_after># -*- coding: utf-8 -*-
# vim: set ts=4 et

import bisect
import inspect
import re
import traceback

url_re = re.compile(
  'https?://[^ /]+\.[^ /]+(?:/[^ ]*)?'  +
  '|'                                   +
  '(?<![^ ])[^ /]+\.[^ /]+/[^ ]*'
)

domain_re = re.compile('https?://(?:www\.)?([^ /]+\.[^ /]+)')

from message import Message

class Hook(object):
    def __init__(self, sort, extra={}):
        self.sort = sort
        self.extra = extra

    def __call__(self, *args):
        if not hasattr(self, 'fn'):
            Exception('attempt to call an unbound hook')
            return

        try:
            return self.fn(*args[:self.nargs])
        except:
            print('%s hook error:' % type(self))
            traceback.print_exc()

    def __lt__(self, other):
        return self.sort < other.sort

    def bind(self, fn, owner=None):
        if owner:
            self.owner = owner
        elif hasattr(fn, '__self__'):
            self.owner = fn.__self__
        else:
            raise Exception('unable to bind hook, no owner!')
        self.fn = fn

        if inspect.ismethod(fn):
            self.nargs = self.fn.__func__.__code__.co_argcount - 1
            self.__func__ = self.fn.__func__
        else:
            self.nargs = self.fn.__code__.co_argcount
            self.__func__ = self.fn

        if not hasattr(self.__func__, '_priority'):
            self.__func__._priority = getattr(self.owner, 'default_priority', 500)
        
        if not hasattr(self.__func__, '_level'):
            self.__func__._level = getattr(self.owner, 'default_level', 1)

class EventHook(Hook):
    def __init__(self, event):
        Hook.__init__(self, event)

class CommandHook(Hook):
    def __init__(self, command):
        Hook.__init__(self, command.upper())

class TriggerHook(Hook):
    def __init__(self, trigger):
{'fraction_non_alphanumeric': 0.15122723673792557, 'fraction_numerical': 0.003694906307732911, 'mean_word_length': 2.0466237942122185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3148152', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1167, 'n_words': 272}