<commit_before>#! /usr/bin/env python


def get_functions_from_module(mod, pattern=None):
    import inspect, re

    funcs = {}
    for name, func in inspect.getmembers(mod, inspect.isroutine):
        if pattern is None or re.match(pattern, name):
            funcs[name] = func
    return funcs


def add_functions_to_class(cls, funcs):
    for name, func in funcs.items():
        setattr(cls, name, func)


def add_module_functions_to_class(cls, module, pattern=None):
    import inspect, imp, os

    caller = inspect.stack()[1]
    path = os.path.join(os.path.dirname(caller[1]), os.path.dirname(module))

    (module, _) = os.path.splitext(os.path.basename(module))

    try:
        mod = imp.load_module(module, *imp.find_module(module, [path]))
    except ImportError:
        print path, module
        raise

    funcs = get_functions_from_module(mod, pattern=pattern)
    add_functions_to_class(cls, funcs)

<commit_msg>Removed debug print statement.<commit_after>#! /usr/bin/env python


def get_functions_from_module(mod, pattern=None):
    import inspect, re

    funcs = {}
    for name, func in inspect.getmembers(mod, inspect.isroutine):
        if pattern is None or re.match(pattern, name):
            funcs[name] = func
    return funcs


def add_functions_to_class(cls, funcs):
    for name, func in funcs.items():
        setattr(cls, name, func)


def add_module_functions_to_class(cls, module, pattern=None):
    import inspect, imp, os

    caller = inspect.stack()[1]
    path = os.path.join(os.path.dirname(caller[1]), os.path.dirname(module))

    (module, _) = os.path.splitext(os.path.basename(module))

    mod = imp.load_module(module, *imp.find_module(module, [path]))

    funcs = get_functions_from_module(mod, pattern=pattern)
    add_functions_to_class(cls, funcs)


{'fraction_non_alphanumeric': 0.12064194798007748, 'fraction_numerical': 0.002213613724405091, 'mean_word_length': 3.542713567839196, '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': '1640419', 'n_tokens_mistral': 614, 'n_tokens_neox': 598, 'n_words': 134}