<commit_before>import importlib
import inspect
import logging
import os
import sys

LOG = logging.getLogger(__name__)
PYTHON_EXTENSIONS = ('.py')


def __register_plugin_path(plugin_dir_abs_path):
    if not os.path.isdir(plugin_dir_abs_path):
        raise Exception('Directory containing plugins must be provided.')
    for x in sys.path:
        if plugin_dir_abs_path in (x, x + os.sep):
            return
    sys.path.append(plugin_dir_abs_path)


def __get_plugin_module(plugin_file_path):
    plugin_module = os.path.basename(plugin_file_path)
    if plugin_module.endswith(PYTHON_EXTENSIONS):
        plugin_module = plugin_module[:plugin_module.rfind('.py')]
    return plugin_module


def __get_classes_in_module(module):
    classes = []
    for name, cls in inspect.getmembers(module):
        if inspect.isclass(cls):
            classes.append(cls)
    return classes


def __get_plugin_classes(module_name):
    return __get_classes_in_module(module_name)


def __register_plugin(plugin_base_class, plugin_instance):
    plugin_base_class.register(plugin_instance)


def register_plugin(plugin_base_class, plugin_abs_file_path):
    instances = []
    plugin_dir = os.path.dirname(os.path.realpath(plugin_abs_file_path))
    __register_plugin_path(plugin_dir)
    module_name = __get_plugin_module(plugin_abs_file_path)
    module = importlib.import_module(module_name)
    klasses = __get_plugin_classes(module)<commit_msg>Rename variable from plugin_instance to plugin_impl<commit_after>import importlib
import inspect
import logging
import os
import sys

LOG = logging.getLogger(__name__)
PYTHON_EXTENSIONS = ('.py')


def __register_plugin_path(plugin_dir_abs_path):
    if not os.path.isdir(plugin_dir_abs_path):
        raise Exception('Directory containing plugins must be provided.')
    for x in sys.path:
        if plugin_dir_abs_path in (x, x + os.sep):
            return
    sys.path.append(plugin_dir_abs_path)


def __get_plugin_module(plugin_file_path):
    plugin_module = os.path.basename(plugin_file_path)
    if plugin_module.endswith(PYTHON_EXTENSIONS):
        plugin_module = plugin_module[:plugin_module.rfind('.py')]
    return plugin_module


def __get_classes_in_module(module):
    classes = []
    for name, cls in inspect.getmembers(module):
        if inspect.isclass(cls):
            classes.append(cls)
    return classes


def __get_plugin_classes(module_name):
    return __get_classes_in_module(module_name)


def __register_plugin(plugin_base_class, plugin_impl):
    plugin_base_class.register(plugin_impl)


def register_plugin(plugin_base_class, plugin_abs_file_path):
    instances = []
    plugin_dir = os.path.dirname(os.path.realpath(plugin_abs_file_path))
    __register_plugin_path(plugin_dir)
    module_name = __get_plugin_module(plugin_abs_file_path)
    module = importlib.import_module(module_name)
    klasses = __get_plugin_classes(module)
{'fraction_non_alphanumeric': 0.08109965635738832, 'fraction_numerical': 0.0, 'mean_word_length': 4.663424124513619, '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': '1865135', 'n_tokens_mistral': 943, 'n_tokens_neox': 927, 'n_words': 168}